How can I print the values of Keras tensors?

后端 未结 7 1426
梦毁少年i
梦毁少年i 2020-12-14 00:43

I am implementing own Keras loss function. How can I access tensor values?

What I\'ve tried

def loss_fn(y_true, y_pred):
    print y_true
         


        
7条回答
  •  独厮守ぢ
    2020-12-14 01:19

    You can't get the values from the tensor symbolic variable directly. Yo need to write a theano function to extract the value. Don't forget to choose theano as backend of Keras.

    Check the notebook link to get some basic of theano variables and functions : get tensor value in call function of own layers

提交回复
热议问题