私はテンソルフローで分類器を作成しようとしていますが、モデルを書いてそれが動作するのをテストしましたが、生産のためにそれを構築したいと考えていますが、モデル に入力し、これは私がpredict_classes関数にテストデータを渡すことによってそれをテストしてきたし、それが作品テンソルフローの分類モデルを提供
#training the neural netork
def get_train_inputs():
x = tf.constant(tr_features)
y = tf.constant(tr_labels)
return x, y
# fit the model using 1000 training steps
classifier.fit(input_fn=get_train_inputs, steps=1000)
#testing the neural network
def get_test_inputs():
x = tf.constant(ts_features)
y = tf.constant(ts_labels)
return x, y
#Calculate accuracy
accuracy_score = classifier.evaluate(input_fn=get_test_inputs, steps=1000)["accuracy"]
print('Test accuracy : ', format(accuracy_score))
を訓練するために使用し、テスト
私のコードで、私の質問は、私はこのためにビルダーを構築します方法です私は外部アプリケーションからデータを渡すことができますか?#test to test prediction
def new_sample():
return np.array(testing,dtype=np.float32)
predictions = list(classifier.predict(input_fn=new_sample))
print('predition : ', format(predictions))
私はそのコードを実装しているが、それは動作するようにdoesntの、ある(classifier.predict(input_fn = new_sample))? –