2017-05-16 5 views
1

私は、フォームのデータを持っている:テンソルフローのデータをモデル化する方法は?

A B C D E F G 
1 0 0 1 0 0 1 
1 0 0 1 0 0 1 
1 0 0 1 0 1 0 
1 0 1 0 1 0 0 
...    
1 0 1 0 1 0 0 
0 1 1 0 0 0 1 
0 1 1 0 0 0 1 
0 1 0 1 1 0 0 
0 1 0 1 1 0 0 

A,B,C,Dは私の入力であり、E,F,Gは私の出力です。

from __future__ import print_function 
#from random import randint 

import numpy as np 
import tflearn 
import pandas as pd 


data,labels =tflearn.data_utils.load_csv('dummy_data.csv',target_column=-1,categorical_labels=False, n_classes=None) 

print(data) 
# Build neural network 
net = tflearn.input_data(shape=[None, 4]) 
net = tflearn.fully_connected(net, 8) 
net = tflearn.fully_connected(net, 8) 
net = tflearn.fully_connected(net, 3, activation='softmax') 
net = tflearn.regression(net) 

# Define model 
model = tflearn.DNN(net) 
#Start training (apply gradient descent algorithm) 
data_to_array = np.asarray(data) 
print(data_to_array.shape) 
#data_to_array= data_to_array.reshape(6,9) 
print(data_to_array.shape) 
model.fit(data_to_array, labels, n_epoch=10, batch_size=3, show_metric=True) 

私が言うエラー取得しています:私は私の入力データは7列(0を持っているので、これは推測してい

ValueError: Cannot feed value of shape (3, 6) for Tensor 'InputData/X:0' , which has shape '(?, 4)'

を... 6私はTensorFlowを使用してPythonで次のコードを書きました)しかし、私は入力層が最初の4つの列だけを入力として取り、データの最後の3つの列を出力として予測したいと思います。これをどのようにモデル化できますか?

答えて

2

numpyの形式のデータの場合、最初の4列は、単純なスライスで撮影されている:

data[:,0:4] 

:は、「すべての行」を意味し、0:4は値0,1,2の範囲であり、第一3列。

データがnumpy形式でない場合は、データをnumpy形式に変換して簡単にスライスすることができます。

は、ここでnumpyのスライス上の関連記事です:Numpy - slicing 2d row or column vector from array

+0

しかし、私は私の出力であり、最後の3列(E、F、G)を養うかどこ? – Shreyas

+0

あなたは確かにあなたのラベルの入力を宣言する必要があります。 –

関連する問題