Python Tensorflow:不支持将字符串强制转换为浮点值。尽管数据中没有字符串,但使用tflearn时出错

Python Tensorflow:不支持将字符串强制转换为浮点值。尽管数据中没有字符串,但使用tflearn时出错,python,tensorflow,tflearn,Python,Tensorflow,Tflearn,我似乎无法在代码中找到错误,因为有任何字符串被错误地转换为浮点。但它给了我一个错误: W tensorflow/core/framework/op_kernel.cc:958] Unimplemented: Cast string to float is not supported E tensorflow/core/common_runtime/executor.cc:334] Executor failed to create kernel. Unimplemented: Cast stri

我似乎无法在代码中找到错误,因为有任何字符串被错误地转换为浮点。但它给了我一个错误:

W tensorflow/core/framework/op_kernel.cc:958] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:334] 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:958] Unimplemented: Cast string to float is not supported
E tensorflow/core/common_runtime/executor.cc:334] Executor failed to create kernel. Unimplemented: Cast string to float is not supported
     [[Node: Adam/apply_grad_op_0/update_Conv2D/W/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@Conv2D/W"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]
--
Traceback (most recent call last):
  File "code.py", line 63, in <module>
    snapshot_step = 100, show_metric = True, run_id = 'convnet_images')
  File "/usr/local/lib/python2.7/dist-packages/tflearn/models/dnn.py", line 214, in fit
    callbacks=callbacks)
  File "/usr/local/lib/python2.7/dist-packages/tflearn/helpers/trainer.py", line 304, in fit
    show_metric)
  File "/usr/local/lib/python2.7/dist-packages/tflearn/helpers/trainer.py", line 759, in _train
    feed_batch)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 717, in run
    run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 915, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 985, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.UnimplementedError: Cast string to float is not supported
     [[Node: Adam/apply_grad_op_0/update_Conv2D/W/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@Conv2D/W"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]

Caused by op u'Adam/apply_grad_op_0/update_Conv2D/W/Cast_2', defined at:
  File "code.py", line 59, in <module>
    model = tflearn.DNN(network, tensorboard_verbose = 3)
  File "/usr/local/lib/python2.7/dist-packages/tflearn/models/dnn.py", line 63, in __init__
    best_val_accuracy=best_val_accuracy)
  File "/usr/local/lib/python2.7/dist-packages/tflearn/helpers/trainer.py", line 119, in __init__
    clip_gradients)
  File "/usr/local/lib/python2.7/dist-packages/tflearn/helpers/trainer.py", line 649, in initialize_training_ops
    name="apply_grad_op_" + str(i))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 322, in apply_gradients
    update_ops.append(self._apply_dense(grad, var))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/adam.py", line 135, in _apply_dense
    math_ops.cast(self._lr_t, var.dtype.base_dtype),
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 616, in cast
    return gen_math_ops.cast(x, base_type, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 419, in cast
    result = _op_def_lib.apply_op("Cast", x=x, DstT=DstT, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()

UnimplementedError (see above for traceback): Cast string to float is not supported
     [[Node: Adam/apply_grad_op_0/update_Conv2D/W/Cast_2 = Cast[DstT=DT_FLOAT, SrcT=DT_STRING, _class=["loc:@Conv2D/W"], _device="/job:localhost/replica:0/task:0/cpu:0"](Adam/apply_grad_op_0/learning_rate)]]

我也有同样的问题,你写道:

learning_rate = '0.001'
但是
learning\u rate
是一个
float
而不是
string
,所以只要写下:

learning_rate = 0.001

你解决过这个问题吗?使用tflearn.data\u utils.image\u预加载程序时,我也遇到同样的问题
learning_rate = 0.001