我正在尝试在Windows上遵循TensorFlow教程: https://www.tensorflow.org/tutorials/eager/custom_training_walkthrough
特别是我在本节中遇到问题:
plt.scatter(features['petal_length'],
features['sepal_length'],
c=labels,
cmap='viridis')
plt.xlabel("Petal length")
plt.ylabel("Sepal length");
关于c =标签,将返回以下错误:TypeError:类型为'tensorflow.python.framework.ops.EagerTensor'的对象没有len()
答案 0 :(得分:1)
此后,我确定需要按如下所示转换为numpy数组:
plt.scatter(features['petal_length'],
features['sepal_length'],
c=labels.numpy(),
cmap='viridis')
plt.xlabel("Petal length")
plt.ylabel("Sepal length");