2017-08-19 10 views
2

model.fitのaccジャイロは(200 * 3)、入力層の形状は(200 * 3)です。なぜそのような問題がありますか?入力をチェックしているときにエラーが発生しました:acc_inputが3次元であるが、形状(200,3)の配列が得られました。これは私のモデルの可視化です。 (200 * 3)であるmodel.fitでケラス入力層(Nnoe、200,3)、なぜですか?入力は3次元ですが、形状(200,3)の配列を持っています

WIDE = 20 
FEATURE_DIM = 30 
CHANNEL = 1 
CONV_NUM = 64 
CONV_LEN = 3 
CONV_LEN_INTE = 3#4 
CONV_LEN_LAST = 3#5 
CONV_NUM2 = 64 
CONV_MERGE_LEN = 8 
CONV_MERGE_LEN2 = 6 
CONV_MERGE_LEN3 = 4 
rnn_size=128 

acc_input_tensor = Input(shape=(200,3),name = 'acc_input') 
gyro_input_tensor = Input(shape=(200,3),name= 'gyro_input') 
Acc_input_tensor = Reshape(target_shape=(20,30,1))(acc_input_tensor) 
Gyro_input_tensor = Reshape(target_shape=(20,30,1))(gyro_input_tensor) 
acc_conv1 = Conv2D(CONV_NUM,(1, 1*3*CONV_LEN),strides=  (1,1*3),padding='valid',activation=None)(Acc_input_tensor) 
acc_conv1 = BatchNormalization(axis=1)(acc_conv1) 
acc_conv1 = Activation('relu')(acc_conv1) 
acc_conv1 = Dropout(0.2)(acc_conv1) 
acc_conv2 = Conv2D(CONV_NUM,(1,CONV_LEN_INTE),strides= (1,1),padding='valid',activation=None)(acc_conv1) 
acc_conv2 = BatchNormalization(axis=1)(acc_conv2) 
acc_conv2 = Activation('relu')(acc_conv2) 
acc_conv2 = Dropout(0.2)(acc_conv2) 

acc_conv3 = Conv2D(CONV_NUM,(1,CONV_LEN_LAST),strides=(1,1),padding='valid',activation=None)(acc_conv2) 
acc_conv3 = BatchNormalization(axis=1)(acc_conv3) 
acc_conv3 = Activation('relu')(acc_conv3) 
acc_conv3 = Dropout(0.2)(acc_conv3) 
gyro_conv1 = Conv2D(CONV_NUM,(1, 1*3*CONV_LEN),strides=(1,1*3),padding='valid',activation=None)(Gyro_input_tensor) 
gyro_conv1 = BatchNormalization(axis=1)(gyro_conv1) 
gyro_conv1 = Activation('relu')(gyro_conv1) 
gyro_conv1 = Dropout(0.2)(gyro_conv1) 

gyro_conv2 = Conv2D(CONV_NUM,(1, CONV_LEN_INTE),strides=(1,1),padding='valid',activation=None)(gyro_conv1) 
gyro_conv2 = BatchNormalization(axis=1)(gyro_conv2) 
gyro_conv2 = Activation('relu')(gyro_conv2) 
gyro_conv2 = Dropout(0.2)(gyro_conv2) 

gyro_conv3 = Conv2D(CONV_NUM,(1, CONV_LEN_LAST),strides=(1,1),padding='valid',activation=None)(gyro_conv2) 
gyro_conv3 = BatchNormalization(axis=1)(gyro_conv3) 
gyro_conv3 = Activation('relu')(gyro_conv3) 
gyro_conv3 = Dropout(0.2)(gyro_conv3) 
sensor_conv_in = concatenate([acc_conv3, gyro_conv3], 2) 
sensor_conv_in = Dropout(0.2)(sensor_conv_in) 
sensor_conv1 = Conv2D(CONV_NUM2,kernel_size=(2, CONV_MERGE_LEN),padding='SAME')(sensor_conv_in) 
sensor_conv1 = BatchNormalization(axis=1)(sensor_conv1) 
sensor_conv1 = Activation('relu')(sensor_conv1) 
sensor_conv1 = Dropout(0.2)(sensor_conv1) 
sensor_conv2 = Conv2D(CONV_NUM2,kernel_size=(2, CONV_MERGE_LEN2),padding='SAME')(sensor_conv1) 
sensor_conv2 = BatchNormalization(axis=1)(sensor_conv2) 
sensor_conv2 = Activation('relu')(sensor_conv2) 
sensor_conv2 = Dropout(0.2)(sensor_conv2) 

sensor_conv3 = Conv2D(CONV_NUM2,kernel_size=(2, CONV_MERGE_LEN3),padding='SAME')(sensor_conv2) 
sensor_conv3 = BatchNormalization(axis=1)(sensor_conv3) 
sensor_conv3 = Activation('relu')(sensor_conv3) 

conv_shape = sensor_conv3.get_shape() 
print conv_shape 
x1 = Reshape(target_shape=(int(conv_shape[1]), int(conv_shape[2]*conv_shape[3])))(sensor_conv3) 

x1 = Dense(64, activation='relu')(x1) 

gru_1 = GRU(rnn_size, return_sequences=True, init='he_normal', name='gru1')(x1) 
gru_1b = GRU(rnn_size, return_sequences=True, go_backwards=True, init='he_normal', name='gru1_b')(x1) 
gru1_merged = merge([gru_1, gru_1b], mode='sum') 

gru_2 = GRU(rnn_size, return_sequences=True, init='he_normal', name='gru2')(gru1_merged) 
gru_2b = GRU(rnn_size, return_sequences=True, go_backwards=True, init='he_normal', name='gru2_b')(gru1_merged) 
x = merge([gru_2, gru_2b], mode='concat') 
x = Dropout(0.25)(x) 
n_class=2 
x = Dense(n_class)(x) 
model = Model(input=[acc_input_tensor,gyro_input_tensor], output=x) 
model.compile(loss='mean_squared_error',optimizer='adam') 
model.fit(inputs=[acc,gyro],outputs=labels,batch_size=1, validation_split=0.2, epochs=2,verbose=1 , 
     shuffle=False) 

ACCジャイロがある(* 3 200)、入力層の形状で:

enter image description here

は、ここに私のコードです。なぜそのような問題がありますか?入力エラーチェック:期待acc_input理由は、入力配列を作成または再形成の際に、3次元を有するが、

+0

ですが、あなたのモデルをどのように可視化しましたか? – Paddy

+0

これは、ディーエップネットワークです。膨大な量のデータがあることを願ってください。 – DJK

答えて

0

形状(None, 200, 3)Nonebatch_sizeを意味し、バッチについてKerasに使用される(3、200)形状のアレイを持ってしバッチサイズが不明な場合がありますので、batch_size = 128を使用する場合、バッチインプットマトリックスの形状は(128, 200, 3)

関連する問題