AiriSelege 2019-04-16 16:06 采纳率: 9.1%
浏览 3301

Using a tf.Tensor as a Python bool is not allowed这个报错该如何解决?

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,问题应该出在这里,但完全不知道如何解决,跪求大佬教教我

  • 写回答

1条回答 默认 最新

  • 在路上。。。。 2021-03-09 22:02
    关注

    请问一下您的问题如何解决的啊,我也遇到了这个问题,方便的话,能否告知一下

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型