[error] TypeError: 'Tensor' object is not callable in custom loss

2021. 5. 24. 18:27공부한 것 정리/개발환경설정

반응형

ref : https://discuss.pytorch.org/t/typeerror-tensor-object-is-not-callable/102931

 

TypeError: ‘Tensor’ object is not callable

Hello,everyone. Newbie here, trying to learn pytorch. Recently, I’m using lstm or gru to do failure prediction. This is a binary classification problem ,so I use BCEWithLogitsLoss as the loss function, but finally, it is wrong. %matplotlib notebook impor

discuss.pytorch.org

custom loss 만들어서 쓰는데, TypeError: 'Tensor' object is not callable 발생함

 

원인 : loss function이름과 return하는 인자 값 이름이 같아서 발생

 

loss = loss(pred, ground_truth ) 하면 안됨 이름이 똑같으면 안되서

loss = custom_loss(pred, ground_truth ) 해야 됨~~

반응형