我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用keras.layers.convolutional.UpSampling1D()。
def generator_model(noise_dim=100, aux_dim=47, model_name="generator"): # Merge noise and auxilary inputs gen_input = Input(shape=(noise_dim,), name="noise_input") aux_input = Input(shape=(aux_dim,), name="auxilary_input") x = concatenate([gen_input, aux_input], axis=-1) # Dense Layer 1 x = Dense(10 * 100)(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 10*100 # Reshape the tensors to support CNNs x = Reshape((100, 10))(x) # shape is 100 x 10 # Conv Layer 1 x = Conv1D(filters=250, kernel_size=13, padding='same')(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 100 x 250 x = UpSampling1D(size=2)(x) # output shape is 200 x 250 # Conv Layer 2 x = Conv1D(filters=100, kernel_size=13, padding='same')(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 200 x 100 x = UpSampling1D(size=2)(x) # output shape is 400 x 100 # Conv Layer 3 x = Conv1D(filters=1, kernel_size=13, padding='same')(x) x = BatchNormalization()(x) x = Activation('tanh')(x) # final output shape is 400 x 1 generator_model = Model( outputs=[x], inputs=[gen_input, aux_input], name=model_name) return generator_model
def generator_model(): # CDNN Model print(INPUT_LN, N_GEN_l, CODE_LN) model = Sequential() model.add(Convolution1D(16, 5, border_mode='same', input_shape=(CODE_LN, 1))) model.add(Activation('relu')) model.add(UpSampling1D(length=N_GEN_l[0])) model.add(Convolution1D(32, 5, border_mode='same')) model.add(Activation('relu')) model.add(UpSampling1D(length=N_GEN_l[1])) model.add(Convolution1D(1, 5, border_mode='same')) model.add(Activation('tanh')) return model
def test_upsampling_1d(): layer_test(convolutional.UpSampling1D, kwargs={'length': 2}, input_shape=(3, 5, 4))
def generator_model_44(): # CDNN Model model = Sequential() model.add(Convolution1D(16, 5, border_mode='same', input_shape=(CODE_LN, 1))) model.add(Activation('relu')) model.add(UpSampling1D(length=4)) model.add(Convolution1D(32, 5, border_mode='same')) model.add(Activation('relu')) model.add(UpSampling1D(length=4)) model.add(Convolution1D(1, 5, border_mode='same')) # model.add(Activation('relu')) return model
def generator_model(): # CDNN Model model = Sequential() model.add(Convolution1D(16, 5, border_mode='same', input_shape=(CODE_LN, 1))) model.add(Activation('relu')) model.add(UpSampling1D(length=4)) model.add(Convolution1D(32, 5, border_mode='same')) model.add(Activation('relu')) model.add(UpSampling1D(length=4)) model.add(Convolution1D(1, 5, border_mode='same')) # model.add(Activation('relu')) return model
def generator_model(noise_dim=100, aux_dim=47, model_name="generator"): # Merge noise and auxilary inputs gen_input = Input(shape=(noise_dim,), name="noise_input") aux_input = Input(shape=(aux_dim,), name="auxilary_input") x = merge([gen_input, aux_input], mode="concat", concat_axis=-1) # Dense Layer 1 x = Dense(10 * 100)(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 10*100 # Reshape the tensors to support CNNs x = Reshape((100, 10))(x) # shape is 100 x 10 # Conv Layer 1 x = Convolution1D(nb_filter=250, filter_length=13, border_mode='same', subsample_length=1)(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 100 x 250 x = UpSampling1D(length=2)(x) # output shape is 200 x 250 # Conv Layer 2 x = Convolution1D(nb_filter=100, filter_length=13, border_mode='same', subsample_length=1)(x) x = BatchNormalization()(x) x = LeakyReLU(0.2)(x) # output shape is 200 x 100 x = UpSampling1D(length=2)(x) # output shape is 400 x 100 # Conv Layer 3 x = Convolution1D(nb_filter=1, filter_length=13, border_mode='same', subsample_length=1)(x) x = BatchNormalization()(x) x = Activation('tanh')(x) # final output shape is 400 x 1 generator_model = Model( input=[gen_input, aux_input], output=[x], name=model_name) return generator_model