2017-02-20 24 views
0

私はすでに訓練された機械学習モデルで操作を実行するTensorFlowのプロジェクトに取り組んでいます。チュートリアルTFLearn Quickstartの後、私はTitanic Datasetからの生存を予測する深いニューラルネットワークを構築しました。私はTensorFlowモデルを使用するのと同じ方法でTFLearnモデルを使用したいと思います。TensorFlowテンソルをTFLearnモデルに渡す方法

TFLearnドキュメントのホームページには、これは私が私がTFLearnモデルになどの入力としてテンソルを渡すことができるだろうと思わせる

Full transparency over Tensorflow. All functions are built over tensors and can be used independently of TFLearn

を言います。現在

# Build neural network 
net = tflearn.input_data(shape=[None, 6]) 
net = tflearn.fully_connected(net, 32) 
net = tflearn.fully_connected(net, 32) 
net = tflearn.fully_connected(net, 2, activation='softmax') 
net = tflearn.regression(net) 

# Define model 
model = tflearn.DNN(net) 
# Start training (apply gradient descent algorithm) 
model.fit(data, labels, n_epoch = 10, batch_size = 16, show_metric = False) 

test = preprocess([[3, 'Jack Dawson', 'male', 19, 0, 0, 'N/A', 5.0000]], to_ignore) 
# Make into a tensor 
testTF = [tf.constant(i) for i in test] 
# Pass the tensor into the predictor 
print(model.predict([testTF])) 

、私はとValueErrorで迎えていモデルに渡すテンソル:配列と配列要素を設定します。

具体的には、テンソルをTFLearnモデルにどのように渡すことができますか? 一般に、TFLearnモデルでテンソルを使用する方法にはどのような制限がありますか?

答えて

0

あなたはまだあなたの問題への答えを探しているなら、私は知らないが、私は問題はあなたの非常に最後の行にあると思う:

print(model.predict([testTF])) 

が代わりにこれを試してみてください:

print(model.predict(testTF)) 

あなたは別のリストの中にリストをネストしたと思います。これはTFlearn問題ではありませんそれ自体はです。希望が役立ちます。

関連する問題