2016-11-13 3 views
0

현재 입력 데이터를 원하는 출력 데이터에 매핑 할 수있는 선형 회귀 네트워크를 만들고자합니다.내 모델을 교육 할 수없는 이유는 무엇입니까

내 입력과 출력은 현재 numpy.ndarray로 저장된 행렬 목록으로 저장됩니다.

회귀 네트워크의 입력 치수 400 이며 회귀 네트워크의 출력 사이즈 치수 입력측 행렬 각각 13

갖는다 [400 X] 잉크 입력 [0 의해 => 출력 ] .shape

출력측의 각 행렬은 크기 [13, X] 인쇄 산출 => 출력 [0]

I은 ​​다음과 같다를 정의한 네트워크 .shape 가지고

print "Training!" 
model = Sequential() 
model.add(Dense(output_dim=13, input_dim=400, init="normal")) 
model.add(Activation("relu")) 
print "Compiling" 
model.compile(loss='mean_squared_error', optimizer='sgd') 
model.fit(input,output,verbose=1) 

문제는 열차 단계입니다.

어떻게 든 시간이 오래 걸리고 진행 상황에 대한 정보가 제공되지 않습니다. 시스템이 멈춘 것처럼 보이고이 오류 메시지로 종료되었습니다.

Traceback (most recent call last): 
    File "tensorflow_datapreprocess_mfcc_extraction_rnn.py", line 169, in <module> 
    model.fit(train_set_data,train_set_output,verbose=1) 
    File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 620, in fit 
    sample_weight=sample_weight) 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1034, in fit 
    batch_size=batch_size) 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 961, in _standardize_user_data 
    exception_prefix='model input') 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 51, in standardize_input_data 
    '...') 
Exception: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 arrays but instead got the following list of 270 arrays: [array([[ -1.52587891e-04, 3.05175781e-05, -1.52587891e-04, 
     -5.18798828e-04, 3.05175781e-05, -3.96728516e-04, 
      1.52587891e-04, 3.35693359e-04, -9.15527344e-05, 
      3.3... 

내 생각에 오류는 내 입력 데이터를 구문 분석하는 방식 일 수 있습니다. 내 입력 데이터는 검은 색 마술입니다. 문서는 상태

https://keras.io/models/model/

fit(self, x, y, batch_size=32, nb_epoch=10, verbose=1, callbacks=[], validation_split=0.0, validation_data=None, shuffle=True, class_weight=None, sample_weight=None) 

그 X : NumPy와 배열의 NumPy와 훈련 데이터의 배열 또는 게시하면 여러 개의 입력을 가지고 모델. 모델의 모든 입력의 이름이 지정되면 도 Numpy 배열에 입력 이름을 매핑하는 사전을 전달할 수 있습니다.

y : 모델 에 여러 개의 출력이있는 경우 대상 데이터의 너비가 많은 배열 또는 Numpy 배열 목록. 모델의 모든 출력의 이름이 지정되면 도 Numpy 배열에 출력 이름 매핑 사전을 전달할 수 있습니다.

Numpy 배열 목록은 무엇입니까? 그것이 읽어야하는 행을 어떻게 알 수 있습니까? ... 모르겠습니다. numpy.ndarrays는 각 배열이 행인 numpy.arrays 목록으로 저장됩니다.

그것은 매우 간단한 예제에 따라 같다 :

입력 :

import numpy as np 

lis = [] 
output_data = np.random.rand(5,3) 
output_data_1 = np.random.rand(5,2) 
lis.append(output_data) 
lis.append(output_data_1) 
print output_data.shape 
print output_data_1.shape 
print lis 

출력 : 내가 잘못 뭐하는 거지 그래서

(5, 3) 
(5, 2) 
[array([[ 0.15509364, 0.20140267, 0.13678847], 
     [ 0.2, 0.38430659, 0.87265863], 
     [ 0.01053336, 0.28403731, 0.19749507], 
     [ 0.95775409, 0.96032907, 0.46996195], 
     [ 0.29515174, 0.74466708, 0.78720968]]), array([[ 0.34216058, 0.74972468], 
     [ 0.97262113, 0.84451951], 
     [ 0.72230052, 0.30852572], 
     [ 0.47586734, 0.03382701], 
     [ 0.37998285, 0.80772875]])] 

? 왜 데이터를 모델로 전달할 수 없습니까?

+0

모양에 'x'가 무엇입니까? "입력측의 각 행렬은 [400, x] => 프린트 입력 [0]에 의해 출력 된 치수를가집니다.모양 출력면의 각 행렬은 치수 [13, x] => 인쇄물 출력 [0] .shape " – pyan

+0

x이고 y는 numpy.ndarrays의 목록입니다. –

답변

1

입력 numpy 배열을 조 변경하십시오. Keras는 입력 배열이 (number_of_samples, number_of_features) 모양이어야합니다.

+0

so ... x.shape? 또는 x [0] .shape? –

+0

시도해 보셨습니까? – pyan

+0

입력이 numpy.ndarrays 목록이므로 input.shape을 출력 할 수 없습니다. 하지만 입력 [0] .shape을 줄 수 있습니다. .. 어느 :.. (400, 288) (400)가 입력 기능 및 288 번호는 동일한 출력 간다 –

관련 문제