# 파라미터 놈이 inf가 떠도 괜찮은건가요?

**URL:** https://discuss.pytorch.kr/t/inf/191
**Category:** 묻고 답하기
**Created:** [3월 5, 2022, 5:12오전 UTC](https://discuss.pytorch.kr/t/inf/191 "2022-03-05T05:12:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![steelblaze](https://discuss.pytorch.kr/user_avatar/discuss.pytorch.kr/steelblaze/32/146_2.png) [@steelblaze](https://discuss.pytorch.kr/u/steelblaze)
#### Post date: [3월 5, 2022, 5:12오전 UTC](https://discuss.pytorch.kr/t/inf/191/1 "2022-03-05T05:12:18Z")

</div>

코드 속도가 너무 느려서 프로파일러로 조사를 하던 중이었습니다.

iteration 내에서  
파라미터 놈(L2)은 마지막 쯔음에서 inf가 되고(전체 파라미터 127개중 마지막 2개에서. 초반부를 좀 조사해본 결과 매 iteration에서 동일하게 나타남))  
그라디언트 놈은 가끔식 0이 뜨더군요.

@profile  
def 겟\_파라미터\_norm(파라미터들, norm\_type=2):  
전체\_norm = 0  
try:  
for 파라미터 in 파라미터들:  
전체\_norm += (파라미터.data \*\* norm\_type).sum() #시간 많이 잡아먹음

파라미터 놈은 클수록 좋고,  
그라디언트 놈은 작을수록 좋은 걸로 알고 있는데요.  
i아무리 그래도 inf가 떠도 괜찮은건가요?
