问题描述
我正在尝试使用Keras + TensorFlow编写自定义损失函数。尝试添加按元素的乘法运算时遇到错误:
def new_loss(y_true,y_pred):
pi = np.pi
d = pi/4 + (pi/4) * (y_pred - y_true)
a = tf.keras.layers.Multiply()([K.sin(d),-K.log(K.cos(d))])
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must Feed a value for placeholder tensor 'dense_2_target' with dtype float and shape [?,?]
[[node dense_2_target (defined at Q:\PycharmProjects\loss_function\custom_loss.py:25) ]] [Op:__inference_keras_scratch_graph_164]
PS:由于我在Tensors上进行操作,是否真的需要在TensorFlow中编写这些操作?我可以将'y_true'和'y_pred'转换为Numpy数组吗?该怎么做?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)