this questionのような問題があります。カスタム損失関数のテンソルを変更
this questionに与えられた回答に基づいてdef depth_loss_func(lr):
def loss(actual_depth,pred_depth):
actual_shape = actual_depth.get_shape().as_list()
dim = np.prod(actual_shape[1:])
actual_vec = K.reshape(actual_depth,[-1,dim])
pred_vec = K.reshape(pred_depth,[-1,dim])
di = K.log(pred_vec)-K.log(actual_vec)
di_mean = K.mean(di)
sq_mean = K.mean(K.square(di))
return (sq_mean - (lr*di_mean*di_mean))
return loss
:私はとして与えられたkerasで損失関数を考案しようとしています。しかし、私はエラーを取得しています:
TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
具体的に、この文は、バックエンドがTensorFlowで次の出力に
(Pdb) actual_depth.get_shape()
TensorShape([Dimension(None), Dimension(None), Dimension(None)])
を与えます。ご協力いただきありがとうございます。
これがあなたの問題を解決したことをうれしく思います。あなたのコーディングで幸運を祈る。あなたがこの回答を見つけたら、それを上書きすることも検討してください。 – DarkCygnus
ありがとう@GrayCygnus! – shunyo