Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 函数调用堆栈:train_函数_Python_Python 3.x_Tensorflow_Machine Learning_Keras - Fatal编程技术网

Python 函数调用堆栈:train_函数

Python 函数调用堆栈:train_函数,python,python-3.x,tensorflow,machine-learning,keras,Python,Python 3.x,Tensorflow,Machine Learning,Keras,在培训使用keras创建的功能模型时,我遇到以下错误: File "D:\Age_prediction\testmatrixshape.py", line 34, in <module> cnn_lstm.fit(X_train, y_train, batch_size=10, epochs=10) File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib

在培训使用keras创建的功能模型时,我遇到以下错误:

File "D:\Age_prediction\testmatrixshape.py", line 34, in <module>
    cnn_lstm.fit(X_train, y_train, batch_size=10, epochs=10)
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\training.py", line 66, in _method_wrapper
    return method(self, *args, **kwargs)
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\training.py", line 848, in fit
    tmp_logs = train_function(iterator)
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\def_function.py", line 580, in __call__
    result = self._call(*args, **kwds)
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\def_function.py", line 644, in _call
    return self._stateless_fn(*args, **kwds)
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\function.py", line 2420, in __call__
    return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\function.py", line 1661, in _filtered_call
    return self._call_flat(
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\function.py", line 1745, in _call_flat
    return self._build_call_outputs(self._inference_function.call(
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\function.py", line 593, in call
    outputs = execute.execute(
  File "C:\Users\Pranaswi Reddy\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.UnimplementedError:  Cast string to float is not supported
     [[node Cast (defined at D:\Age_prediction\testmatrixshape.py:34) ]] [Op:__inference_train_function_2171]

Function call stack:
train_function

检查所有输入是否不包含任何“字符串”类型的数据。如果是这样,请更改它们,例如,您可以使用TensorFlow分类列函数

我的问题是,我打开了同一程序的另一个外壳。尝试检查窗口是否加倍。

在代码之前添加此代码

from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)

感谢您的快速回复。我正在根据语音信号进行年龄预测。目标列中有两个标签,成人和年轻。这就是产生上述错误的原因。您建议我使用TensorFlow分类函数。但我不知道如何使用,当我检查时,我发现有两个函数是feature\u column.embeddeding\u column和feature\u column.indicator\u column。现在我不知道该使用哪一个。具体要做什么。如果你回应,我会觉得这是一个很大的帮助。从最简单的事情开始:你的输入(X\u train,y\u train)是否包含字符串?这很有效,但为什么?
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession

config = ConfigProto()
config.gpu_options.allow_growth = True
session = InteractiveSession(config=config)