我在学习代码时遇到了一些问题,因为当我执行代码时,它返回以下错误
错误
Traceback (most recent call last):
File "tf_apprentissage/main.py", line 109, in <module>
f_de_x = model(x) # permet de déterminer ce qu'est l'image (y = f(x) )
File "tf_apprentissage/main.py", line 91, in model
c9 = dense(c7, (-1,100, 2))
File "tf_apprentissage/main.py", line 61, in dense
w = tf.Variable(tf.truncated_normal(forme, stddev=(2/n)**.5)) # poid
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/ops/random_ops.py", line 169, in truncated_normal
stddev_tensor = ops.convert_to_tensor(stddev, dtype=dtype, name="stddev")
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 836, in convert_to_tensor
as_ref=False)
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site- packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 383, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/home/etudiant/PycharmProjects/tf_apprentissage/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 303, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected float32, got (8.659560562354934e-17+1.4142135623730951j) of type 'complex' instead.
我是Tensorflow的初学者,所以我不知道问题出在哪里,我将非常感谢任何帮助。在
这个源代码的目标是识别类项目的单词,我们首先要识别字母和数字。我以前从未做过任何机器学习项目,这是我第一次使用tensorflow。我们使用绘制的数字图像作为输入,并带有一个标签。在
我的代码是
^{pr2}$
forme
似乎是一个复数,在你引用的forme[0]
的上面和下面的行上,我假设它是复数的实部。而在上面所示的行中,forme
被引用,而没有对数字实部的索引。在你想要:
^{pr2}$如果不是,请打印出
forme
的值,并验证它是否是您期望的值。如果你不是有意让它成为一个复数,那就追查这个问题。在相关问题 更多 >
编程相关推荐