TypeError: Input y of Equal Op has type int64 that does not match type int32 of argument x
最新推荐文章于 2022-06-07 11:15:45 发布
最新推荐文章于 2022-06-07 11:15:45 发布
阅读量
2.4k
在运行unet网络的时候报出如下错误:
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: <tf.Tensor 'loss/activation_1_loss/lossFunc/ArgMax:0' shape=(?, ?) dtype=int64>
TypeError: Input 'y' of 'Equal' Op has type int64 that does not match type int32 of argument 'x'.
原因:根据错误提示,原因是类型不匹配导致的。
检查代码,锁定到classSelectors = K.argmax(true, axis=axis)这一行代码,查看类型:
classSelectors = K.argmax(true, axis=axis)
print(classSelectors.dtype)
所以发现错误就在这一行代码。
做如下修改:转换数据类型
classSelectors = tf.cast(classSelectors, tf.int32)
再次查看类型:
print(type(classSelectors))
print(classSelectors.dtype)
可以看出修改完成,再次运行代码,错误成功解决!
公众号:机器学习实战python
运行出错出错:
TypeError
:
Input
'y' of 'AddV2'
Op
has
type
int
32
that does not
match
type
float
32
of
argument
'x'.检查发现是损失函数的数据 类型不一致解决办法:用loss_pi=tf.cast(loss_pi,tf.float
32
)转换成统一的float类型
错误:
TypeError
:
Input
'b' of 'MatMul'
Op
has
type
float
32
that does not
match
type
int
32
of
argument
'a'.
解决方法:构造,转换成同类型
#训练预测
import
tensorflow
x_train_float
32
=
tensorflow
.cast(x_train,
tensorflow
.float
32
)
y_train_predict = model.predict_classes(x_train_f
loss = tf.reduce_mean(
tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels,
num_sampled, vocabulary_size))
TypeError
:
Input
'b'
在学习神经网络时,在加入滑动平均时pycharm报了一个错,
TypeError
:
Input
‘y’ of ‘Minimum’
Op
has
type
float
32
that does not
match
type
int
32
of
argument
‘x’,意思是输入y是float
32
类型的和x是
int
32
类型的不匹配,最后Debug才发现是滑动平均的超参数MOVING_AVERAGE_DEC...
在做多元线性回归的时候多余模型:y = tf.matmul(x_data,w) +b 中:我的x_data 使用tf.placeholder(tf.float
32
,[1,2]) 申明的;而我的输入的是整数解决办法:1:直接把输入输成浮点型的,如:输入3,你可以直接输入3.002:加上类型转换,可以用numpy申明数组的时候通过as
type
(numpy.float
32
) 即:data = np.ar...
class2 week3 3.11 practice
在本节课的视频中,吴恩达老师向我们展示了如何利用
tensorflow
框架进行简单的运算,其中有一段代码:
w = tf.Variable(0, d
type
=tf.float
32
)
# cause we can not add more than 2 object with tf.add
# so we have to use double tf...
这是在做用
tensorflow
读取csv文件中数据时,设置默认值时与数据源中的数据格式不匹配,即,上面的意思是,csv文件中的数据类型是字符型的,而我们设置默认值时设置的时
int
32
型的不匹配
转载于:https://www.cnblogs.com/bluesl/p/9215789.html...
# 创建两个常量节点
node1 = tf.constant([2,5], d
type
=tf.
int
32
)
node2 = tf.constant([1,2], d
type
=tf.float
32
)
#创...
问题一:
TypeError
: Expected
int
32
, got list containing Tensors of
type
‘_Message’ instead.
tensorflow
函数tf.cocat([fw,bw],2)出错:Expected
int
32
, got list containing Tensors of
type
‘_Message’ inst
查看原因是11版本的函
TypeError
:
Input
'split_dim' of 'Split'
Op
has
type
float
32
that does not
match
expected
type
of
int
32
.
1.
TypeError
:
Input
'split_dim' of 'Split'
Op
has
type
float
32
that does not
match
expected
type
of
int
32
.
TensorFlow
版本不同,函数接口修改导致的问题。
API r1.3 - tf.
#原来是这样的:
This is because in
Tensorflow
versions < 0.12.0 the split function takes the
argument
s as:
x = tf.split(0, n_steps, x) # tf.split(axis, num_or_size_splits, value)
#修改成这样的:
The tutorial y...