使用TensorFlow训练神经网络时出现dtype错误

时间:2018-04-18 01:13:17

标签: python tensorflow machine-learning compiler-errors neural-network

我尝试使用字符作为输入来训练分类模型。我的网络基于TensorFlow教程之一。我花了好几个小时的时间来讨论为什么它不会跑。 错误是:

import random

name = input('Entrez votre nom: ')


Kilo = input (name + ' Veux-tu jouer un jeu ')



def play(name):
    randomNumber = random.randrange(0,100)
    guessed = False

want_to_play = True

while want_to_play:


print("Un nombre aléatoire a été généré 1 a 100 ")



while guessed==False:
    userInput = int(input("Entrez votre estimation: "))
    if userInput==randomNumber:
        guessed = True
        print("Bien joué!")
    elif userInput>100:
        print("Notre fourchette est entre 0 et 100, essayez un peu plus bas")
    elif userInput<0:
        print("Notre fourchette est comprise entre 0 et 100, essayez un peu plus haut ")
    elif userInput>randomNumber:
        print("Essayez une fois de plus, un peu plus bas")
    elif userInput < randomNumber:
        print("Essayer une fois de plus, un peu plus haut")

我的代码是:

File "estimator.py", line 96, in main
    steps=train_steps)
ValueError: Labels dtype should be integer. Instead got <dtype: 'string'>.

1 个答案:

答案 0 :(得分:0)

我以前有这个问题。可能有两个原因:

  1. 我使用了Jupyter-Notebook。它具有存储某些特定内容的缓存。您应该清空缓存,例如,重新启动系统。重新启动内核没有用,因为数据仍然存在于内存中。

    我到处搜索,但是解决方案不好。我用两个不同的数据集(MNIST和我创建的另一个)训练了模型,并创建了问题。您应该只尝试一个数据集。如果您使用两个数据集,那就是问题。

  2. 您创建的数据类型与您的模型不同。您应该将输入或代码更改为相同。

相关问题