TypeError:
Using a tf.Tensor as a Python bool is not allowed. Use if t is not None: instead of if t: to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.
def spiky(x):
r1 = 2/(1+pow(math.e,-x))-1
if r1 <= -1+Amin*W/2:
return -1.
else:
return 1.
这是我自己定义的激活函数,输入应该是一个[1,1]的Tensor,问题应该出在这里,但完全不知道如何解决,跪求大佬教教我