我正在尝试在Tflearn中构建一个CNN来处理360x390px图像。我在部署到实际数据集之前在170个图像的小数据集上测试它。 我正在研究Jupyter笔记本。
模型拟合阶段可以开始,但几秒钟之后会抛出一个我不理解的错误:ValueError: Tensor conversion requested dtype int64 for Tensor with dtype int32: 'Tensor("strided_slice/stack_4:0", shape=(1,), dtype=int32)
完整错误日志:
Exception in thread Thread-6:
Traceback (most recent call last):
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 491, in apply_op
preferred_dtype=default_dtype)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 704, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 577, in _TensorTensorConversionFunction
% (dtype.name, t.dtype.name, str(t)))
ValueError: Tensor conversion requested dtype int64 for Tensor with dtype int32: 'Tensor("strided_slice/stack_4:0", shape=(1,), dtype=int32)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/anaconda/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/anaconda/lib/python3.6/site-packages/tflearn/data_flow.py", line 187, in fill_feed_dict_queue
data = self.retrieve_data(batch_ids)
File "/anaconda/lib/python3.6/site-packages/tflearn/data_flow.py", line 222, in retrieve_data
utils.slice_array(self.feed_dict[key], batch_ids)
File "/anaconda/lib/python3.6/site-packages/tflearn/utils.py", line 187, in slice_array
return X[start]
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 497, in _SliceHelper
name=name)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 655, in strided_slice
shrink_axis_mask=shrink_axis_mask)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3568, in strided_slice
shrink_axis_mask=shrink_axis_mask, name=name)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 527, in apply_op
inferred_from[input_arg.type_attr]))
TypeError: Input 'strides' of 'StridedSlice' Op has type int32 that does not match type int64 of argument 'begin'.
我的网络架构似乎没问题,我知道这是一个类型错误,但无法确定其来源。
X是大小的np数组(批次,H,W,C); Y是one_hot np数组,大小(批处理,C)
有关信息,我的网络如下所示:
mynet = input_data(shape=[None,H,W,C])
mynet = conv_2d(mynet,nb_filter=32,filter_size=4,strides=2,activation='relu',regularizer="L2")
mynet = max_pool_2d(mynet,2)
mynet = conv_2d(mynet,nb_filter=64,filter_size=4,strides=2,activation='relu',regularizer="L2")
mynet = max_pool_2d(mynet,2)
mynet = conv_2d(mynet,nb_filter=128,filter_size=4,strides=2,activation='relu',regularizer="L2")
mynet = max_pool_2d(mynet,2)
mynet = fully_connected(mynet,n_units=1024,activation='relu')
mynet = dropout(mynet,0.8)
mynet = fully_connected(mynet,n_units=3,activation='softmax')
mynet = regression(mynet,optimizer='adam',learning_rate=0.01,loss='categorical_crossentropy')
model = tflearn.DNN(mynet)
model.fit(X,Y, n_epoch=20, validation_set=0.15,shuffle=True,show_metric=True) # <== This is where I get the error
感谢您的帮助:)