我想对密集层的输出施加条件。为此,我尝试自定义Keras的Dense层,但是在运行代码时出现错误
@keyframes div{
0%{
opacity: 0;
}
100% {
opacity: 1;
}
}
我将条件放入调用函数中,在该函数中输出对照条件进行检查,即如果<= 0.001,则输出应为一个否则为0.0的输出。我正在使用的Dense层只是Keras Dense层的副本,其中对ValueError: No gradients provided for any variable, check your graph for ops that do not support gradients, between variables ["<tf.Variable 'scope0/rnn/while/lstm_cell/kernel:0' shape=(3, 512) dtype=float32>", "<tf.Variable 'scope0/rnn/while/lstm_cell/recurrent_kernel:0' shape=(128, 512) dtype=float32>", "<tf.Variable 'scope0/rnn/while/lstm_cell/bias:0' shape=(512,) dtype=float32>", "<tf.Variable 'scope0/my_dense/kernel:0' shape=(128, 1) dtype=float32>", "<tf.Variable 'scope0/my_dense/bias:0' shape=(1,) dtype=float32>"] and loss Tensor("Sum:0", shape=(), dtype=float32).
方法进行了一些修改,以实现上述条件。
call
如何使以上代码正常工作?