Python 判断字符串是否包含中文

您所在的位置:网站首页 儿童泥塑作品图片简单漂亮 Python 判断字符串是否包含中文

Python 判断字符串是否包含中文

2024-03-03 19:11| 来源: 网络整理| 查看: 265

tensorflow中if判断相等 (使用==出错using a `tf.Tensor` as a Python `bool` is not allowed)

a=polyfit(t,Y,1);: 好像还是不太行,这种情况下,如果把“if A == B:”改成“if (A == B) is not None:”的话,最后判断只会是A == B,无论随机生成的矩阵A和B是否相同。比如下面的代码里,哪怕x和y打印出来明显是两个数值不同的矩阵,最终结果也永远print x==y。这是为什么呢? [code=python] import tensorflow as tf def simple_mat_mul(x,y): return tf.matmul(x,y) def simple_mat_add(x,y): return tf.add(x,y) @tf.function def simple_mat_op(x,y): if (x == y) is not None: print("x == y") return simple_mat_add(x,y) else: print("x != y") return simple_mat_mul(x,y) x = tf.Variable(tf.random.uniform((4,4))) y = tf.Variable(tf.random.uniform((4,4))) print(x) print(y) print(simple_mat_op(x,y)) [/code]



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3