2017-04-12 12 views
0

私はテンソルフローで分類器を作成しようとしていますが、モデルを書いてそれが動作するのをテストしましたが、生産のためにそれを構築したいと考えていますが、モデル に入力し、これは私が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)) 

答えて

0

私はこれは、あなたが何をしたいのかにかなり似ている多くの ex. のような実装を行うことを提案することでしょう。 checkpoints(Crtl + fチェックポイントファイル)を実装する必要がありますが。そこにあるコードの多くは、プログラム固有のものですが、その要点は、以前に保存したチェックポイントのネットを実行するファイル "eval.py"を作成することです。 eval.pyファイルでは、入力したいファイルを入力することができます。

0

最も簡単な方法は、私が予測=リストで使用できるように入力を渡すんかTensorflowServing

+0

私はそのコードを実装しているが、それは動作するようにdoesntの、ある(classifier.predict(input_fn = new_sample))? –

関連する問題