Tensorflow Executor 无法创建内核。未实现:不支持将字符串转换为浮点数
Tensorflow Executor failed to create kernel. Unimplemented: Cast string to float is not supported
我正在尝试使用 Tensorflow 1.1.0 和 TFLearn 0.3.1 为大量癌症图像 (.png) 构建自定义 CNN 分类器,主要是遵循其他人的 CNN 分类器 here,但是当我尝试拟合我的模型 Tensorflow 抛出以下错误:
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_FullyConnected_1/b/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@FullyConnected_1/b"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_FullyConnected_1/b/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@FullyConnected_1/b"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_conv_1/W/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@conv_1/W"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
我正在使用 tflearn.data_utils.image_preloader 读取 png 文件,但是我也尝试过使用其他一些方法,但似乎总是得到相同的错误。许多研究表明这可能是由于图像文件错误造成的,但是我在获取了十几个 jpg 图像后遇到了同样的问题,所以它必须是其他原因。任何建议将不胜感激,我的代码在下面,更大的项目在我的 git here
import numpy as np
import tflearn
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_utils import image_preloader
from tflearn.layers.core import input_data, fully_connected, dropout
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
def train():
training_path = 'images/train'
image_height = 32
image_width = 32
colour_channels = 3
X, Y = image_preloader(
training_path,
image_shape=(image_height, image_width),
mode='folder',
categorical_labels=True,
normalize=True)
X = np.reshape(X, (-1, image_height, image_width, colour_channels))
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()
network = input_data(shape=[None, image_height, image_width, colour_channels],
data_preprocessing=img_prep,
name='input')
network = conv_2d(network, 32, 3, activation='relu', name='conv_1')
network = max_pool_2d(network, 2)
network = conv_2d(network, 64, 3, activation='relu', name='conv_2')
network = conv_2d(network, 64, 3, activation='relu', name='conv_3')
network = max_pool_2d(network, 2)
network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.5)
network = fully_connected(network, 2, activation='softmax')
network = regression(
network,
optimizer='adam',
loss='categorical_crossentropy',
learning_rate='0.001')
model = tflearn.DNN(
network,
checkpoint_path='tmp/tflearn/cnn/checkpoints/model.tflearn',
tensorboard_verbose=3,
tensorboard_dir='tmp/tflearn/cnn/logs/')
model.fit(
X, Y,
validation_set=0.2,
n_epoch=1000,
shuffle=True,
batch_size=100,
run_id='model',
snapshot_epoch=True)
model.save('tmp/tflearn/cnn/model/model_final.tflearn')
抱歉回答晚了(可能对其他人有帮助)
我有同样的问题,问题出在你写的回归代码中
learning_rate='0.001'
但是学习率是 float
值而不是 string
所以只写:
learning_rate = 0.001
它会起作用
我正在尝试使用 Tensorflow 1.1.0 和 TFLearn 0.3.1 为大量癌症图像 (.png) 构建自定义 CNN 分类器,主要是遵循其他人的 CNN 分类器 here,但是当我尝试拟合我的模型 Tensorflow 抛出以下错误:
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_FullyConnected_1/b/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@FullyConnected_1/b"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_FullyConnected_1/b/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@FullyConnected_1/b"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
W tensorflow/core/framework/op_kernel.cc:983] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:594] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
[[Node: Adam/apply_grad_op_0/update_conv_1/W/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@conv_1/W"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
我正在使用 tflearn.data_utils.image_preloader 读取 png 文件,但是我也尝试过使用其他一些方法,但似乎总是得到相同的错误。许多研究表明这可能是由于图像文件错误造成的,但是我在获取了十几个 jpg 图像后遇到了同样的问题,所以它必须是其他原因。任何建议将不胜感激,我的代码在下面,更大的项目在我的 git here
import numpy as np
import tflearn
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_utils import image_preloader
from tflearn.layers.core import input_data, fully_connected, dropout
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
def train():
training_path = 'images/train'
image_height = 32
image_width = 32
colour_channels = 3
X, Y = image_preloader(
training_path,
image_shape=(image_height, image_width),
mode='folder',
categorical_labels=True,
normalize=True)
X = np.reshape(X, (-1, image_height, image_width, colour_channels))
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()
network = input_data(shape=[None, image_height, image_width, colour_channels],
data_preprocessing=img_prep,
name='input')
network = conv_2d(network, 32, 3, activation='relu', name='conv_1')
network = max_pool_2d(network, 2)
network = conv_2d(network, 64, 3, activation='relu', name='conv_2')
network = conv_2d(network, 64, 3, activation='relu', name='conv_3')
network = max_pool_2d(network, 2)
network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.5)
network = fully_connected(network, 2, activation='softmax')
network = regression(
network,
optimizer='adam',
loss='categorical_crossentropy',
learning_rate='0.001')
model = tflearn.DNN(
network,
checkpoint_path='tmp/tflearn/cnn/checkpoints/model.tflearn',
tensorboard_verbose=3,
tensorboard_dir='tmp/tflearn/cnn/logs/')
model.fit(
X, Y,
validation_set=0.2,
n_epoch=1000,
shuffle=True,
batch_size=100,
run_id='model',
snapshot_epoch=True)
model.save('tmp/tflearn/cnn/model/model_final.tflearn')
抱歉回答晚了(可能对其他人有帮助)
我有同样的问题,问题出在你写的回归代码中
learning_rate='0.001'
但是学习率是 float
值而不是 string
所以只写:
learning_rate = 0.001
它会起作用