【发布时间】:2021-04-07 04:22:15
【问题描述】:
我正在尝试训练一个简单的神经网络,但遇到了这个错误,我尝试了一些在类似问题中找到的其他答案,但没有奏效。我想在 TYPE=0 或 TYPE=1 之间进行分类。最后的链接是我的训练数据集的示例。
tensorflow.python.framework.errors_impl.UnimplementedError: Cast string to float is not supported
[[node sequential/Cast (defined at /Users/Administrator/Desktop/New folder/ne.py:31) ]] [Op:__inference_train_function_587]
Function call stack:
train_function
这是我的神经网络代码
model = keras.Sequential([
keras.layers.Dense(1560, input_shape=(6,), activation='relu'),
keras.layers.Dense(1, activation='sigmoid')
])
model.compile(optimizer='adam', loss=keras.losses.BinaryCrossentropy(from_logits=True), metrics=['accuracy'])
model.fit(X_train, y_train, batch_size=1,epochs=5)
Here is an example of my dataset excel格式希望对你有帮助
MPF MF PSD F95 BMI PARITY TYPE
e001_1 0.0048 0.005 6 0.008 27.6 2 1
e001_2 0.0077 0.005 6 0.008 27.6 2 1
e001_3 0.004 0.005 6 0.008 27.6 2 1
e001_4 0.0024 0.004 6 0.008 27.6 2 1
e001_5 0.0025 0.004 6 0.008 27.6 2 1
e001_6 0.0034 0.004 6 0.008 27.6 2 1
e003_1o 7.52E-04 5.45E-04 6 0.001089918 34 0 0
e003_1o 5.31E-04 5.45E-04 6 0.001089918 34 0 0
e003_1o 6.49E-04 5.45E-04 6 0.001089918 34 0 0
e003_1o 9.98E-04 5.45E-04 6 0.001089918 34 0 0
e003_1o 0.001258642 5.45E-04 6 0.001089918 34 0 0
e003_1o 5.76E-04 5.45E-04 6 0.001089918 34 0 0
【问题讨论】:
-
欢迎堆栈溢出。请在您的问题文本中提供您的示例数据,而不是图片或外部链接。请注意,您的错误不是
train_function,而是训练中的错误是"Cast string to float is not supported" -
希望现在更好,我该如何解决这个错误?
-
7.52E-04等值是浮点数还是字符串? -
浮点数 6.49E-04=6.49*10^-(4)
标签: python tensorflow keras neural-network artificial-intelligence