Where is Keras 2 's channels? -
i once used keras 1 (maybe 1.0.5) multi-category classification. , input in cnn (n, 1, 24, 113) , 113 channel numbers, , kernel size (1, 5). code like:
x_train = x_train.reshape((-1, 1, sliding_window_length, num_sensor_channels)) x_test = x_test.reshape((-1, 1, sliding_window_length, num_sensor_channels)) # network inputs = input(shape=(1, sliding_window_length, num_sensor_channels)) conv1 = elu()(convolution2d(num_filters, filter_size, 1, border_mode='valid', init='normal', activation='relu')(inputs)) conv2 = elu()(convolution2d(num_filters, filter_size, 1, border_mode='valid', init='normal', activation='relu')(conv1)) conv3 = elu()(convolution2d(num_filters, filter_size, 1, border_mode='valid', init='normal', activation='relu')(conv2)) conv4 = elu()(convolution2d(num_filters, filter_size, 1, border_mode='valid', init='normal', activation='relu')(conv3)) reshape1 = reshape((8, num_filters * num_sensor_channels))(conv4) gru1 = gru(num_units_lstm, return_sequences=true, consume_less='mem')(reshape1) gru2 = gru(num_units_lstm, return_sequences=false, consume_less='mem')(gru1) outputs = dense(num_classes, activation='softmax')(gru2) # hardcoded number of sensor channels employed in opportunity challenge num_sensor_channels = 113 # hardcoded number of classes in gesture recognition problem num_classes = 18 # hardcoded length of sliding window mechanism employed segment data sliding_window_length = 24 # length of input sequence after convolutional operations final_sequence_length = 8 # hardcoded step of sliding window mechanism employed segment data sliding_window_step = 12 # batch size batch_size = 100 # number filters convolutional layers num_filters = 64 # size filters convolutional layers filter_size = 5 # number of unit in long short-term recurrent layers num_units_lstm = 128
and these days switched keras keras 2. , networks did not change. , code like:
x_train = x_train.reshape((-1, 1, sliding_window_length, num_sensor_channels)) x_test = x_test.reshape((-1, 1, sliding_window_length, num_sensor_channels)) # network inputs = input(shape=(1, sliding_window_length, num_sensor_channels)) conv1 = elu()( conv2d(filters=num_filters, kernel_size=(1, filter_size), strides=(1, 1), padding='valid', activation='relu', kernel_initializer='normal', data_format='channels_last')(inputs)) conv2 = elu()( conv2d(filters=num_filters, kernel_size=(1, filter_size), strides=(1, 1), padding='valid', activation='relu', kernel_initializer='normal', data_format='channels_last')(conv1)) conv3 = elu()( conv2d(filters=num_filters, kernel_size=(1, filter_size), strides=(1, 1), padding='valid', activation='relu', kernel_initializer='normal', data_format='channels_last')(conv2)) conv4 = elu()( conv2d(filters=num_filters, kernel_size=(1, filter_size), strides=(1, 1), padding='valid', activation='relu', kernel_initializer='normal', data_format='channels_last')(conv3)) # permute1 = permute((2, 1, 3))(conv4) reshape1 = reshape((sliding_window_length - (filter_size - 1) * 4, num_filters * 1))(conv4) # 4 4 convs gru1 = gru(num_units_lstm, return_sequences=true, implementation=0)(reshape1) gru2 = gru(num_units_lstm, return_sequences=false, implementation=0)(gru1) # implementation=2 gpu outputs = dense(num_classes, activation='softmax')(gru2)
and speed seems faster shape strange since didn't know channels ?
is there wrong code , ? thx
it seems keras handles channel parameter himself.
Comments
Post a Comment