DNNClassifierをトレーニングしようとしていますが、モデルをトレーニングしようとすると、この問題が発生し続けます。
AttributeError:モジュール 'tensorflow.python.framework.tensor_shape'に属性 'scalar'がありません
import tensorflow as tf
from sklearn.datasets import fetch_openml
mnist = fetch_openml('mnist_784')
feature_columns = [tf.feature_column.numeric_column("x", shape=[784])]
feature_columns
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(mnist['data'] , mnist['target'])
classifier = tf.estimator.DNNClassifier(hidden_units=[300, 100], n_classes=10,
feature_columns=feature_columns)
def input_train_fn(X,y):
features = {'x':tf.convert_to_tensor(X)}
return features, y.reshape((-1,1)).astype(int)
classifier.train(input_fn=lambda : input_train_fn(X_train, y_train), steps=100000)
最後の行は次のエラーをスローします:-
AttributeError:モジュール 'tensorflow.python.framework.tensor_shape'に属性 'scalar'がありません
tensorflowとtensorflow-estimatorをアップグレードすると役立つ場合があります。
このコミットはGithubtf-estimatorリポジトリ(https://github.com/tensorflow/estimator/commit/561b3f95d4f9041cb7a2fbbfdc94efee16413725#diff-a815f16c6f90bfe736d98b8c99a7c2fcL337)で見つかりました。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加