我正在尝试在 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: object of type 'tensorflow.python.framework.ops.EagerTensor' has no len()
请您参考如下方法:
此后我确定我需要按如下方式转换为 numpy 数组:
plt.scatter(features['petal_length'],
features['sepal_length'],
c=labels.numpy(),
cmap='viridis')
plt.xlabel("Petal length")
plt.ylabel("Sepal length");
