这篇教程Python layers.ActivityRegularization方法代码示例写得很实用,希望能帮到您。
本文整理汇总了Python中keras.layers.ActivityRegularization方法的典型用法代码示例。如果您正苦于以下问题:Python layers.ActivityRegularization方法的具体用法?Python layers.ActivityRegularization怎么用?Python layers.ActivityRegularization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块keras.layers 的用法示例。 在下文中一共展示了layers.ActivityRegularization方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。 示例1: test_activity_regularization# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def test_activity_regularization(): layer = layers.ActivityRegularization(l1=0.01, l2=0.01) # test in functional API x = layers.Input(shape=(3,)) z = layers.Dense(2)(x) y = layer(z) model = Model(x, y) model.compile('rmsprop', 'mse') model.predict(np.random.random((2, 3))) # test serialization model_config = model.get_config() model = Model.from_config(model_config) model.compile('rmsprop', 'mse')
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:18,代码来源:core_test.py
示例2: create_simnet_network# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def create_simnet_network(input_shape, weights): L2_REGULARIZATION = 0.001 input = Input(shape=input_shape) # CNN 1 vgg16 = create_vgg16_network(input_shape, weights) cnn_1 = vgg16(input) # CNN 2 # Downsample by 4:1 cnn_2 = MaxPooling2D(pool_size=(4, 4))(input) cnn_2 = Conv2D(128, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Conv2D(128, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Conv2D(256, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Dropout(0.5)(cnn_2) cnn_2 = Flatten()(cnn_2) cnn_2 = Dense(1024, activation='relu')(cnn_2) # CNN 3 # Downsample by 8:1 cnn_3 = MaxPooling2D(pool_size=(8, 8))(input) cnn_3 = Conv2D(128, (3, 3), padding='same', activation='relu')(cnn_3) cnn_3 = Conv2D(128, (3, 3), padding='same', activation='relu')(cnn_3) cnn_3 = Dropout(0.5)(cnn_3) cnn_3 = Flatten()(cnn_3) cnn_3 = Dense(512, activation='relu')(cnn_3) concat_2_3 = concatenate([cnn_2, cnn_3]) concat_2_3 = Dense(1024, activation='relu')(concat_2_3) l2_reg = ActivityRegularization(l2=L2_REGULARIZATION)(concat_2_3) concat_1_l2 = concatenate([cnn_1, l2_reg]) output = Dense(4096, activation='relu')(concat_1_l2) return Model(input, output)
开发者ID:marco-c,项目名称:autowebcompat,代码行数:38,代码来源:network.py
示例3: create_simnetlike_network# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def create_simnetlike_network(input_shape, weights): L2_REGULARIZATION = 0.005 input = Input(shape=input_shape) # CNN 1 vgg16 = create_vgglike_network(input_shape, weights) cnn_1 = vgg16(input) # CNN 2 # Downsample by 4:1 cnn_2 = MaxPooling2D(pool_size=(4, 4))(input) cnn_2 = Conv2D(32, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Conv2D(32, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Conv2D(64, (3, 3), padding='same', activation='relu')(cnn_2) cnn_2 = Dropout(0.5)(cnn_2) cnn_2 = Flatten()(cnn_2) cnn_2 = Dense(64, activation='relu')(cnn_2) # CNN 3 # Downsample by 8:1 cnn_3 = MaxPooling2D(pool_size=(8, 8))(input) cnn_3 = Conv2D(16, (3, 3), padding='same', activation='relu')(cnn_3) cnn_3 = Conv2D(16, (3, 3), padding='same', activation='relu')(cnn_3) cnn_3 = Dropout(0.5)(cnn_3) cnn_3 = Flatten()(cnn_3) cnn_3 = Dense(32, activation='relu')(cnn_3) concat_2_3 = concatenate([cnn_2, cnn_3]) concat_2_3 = Dense(128, activation='relu')(concat_2_3) l2_reg = ActivityRegularization(l2=L2_REGULARIZATION)(concat_2_3) concat_1_l2 = concatenate([cnn_1, l2_reg]) output = Dense(256, activation='relu')(concat_1_l2) return Model(input, output)
开发者ID:marco-c,项目名称:autowebcompat,代码行数:38,代码来源:network.py
示例4: regularization# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def regularization(layer, layer_in, layerId, tensor=True): l1 = layer['params']['l1'] l2 = layer['params']['l2'] out = {layerId: ActivityRegularization(l1=l1, l2=l2)} if tensor: out[layerId] = out[layerId](*layer_in) return out
示例5: test_keras_import# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def test_keras_import(self): model = Sequential() model.add(ActivityRegularization(l1=2, input_shape=(10,))) model.build() self.keras_type_test(model, 0, 'Regularization')
示例6: test_keras_export# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import ActivityRegularization [as 别名]def test_keras_export(self): tests = open(os.path.join(settings.BASE_DIR, 'tests', 'unit', 'keras_app', 'keras_export_test.json'), 'r') response = json.load(tests) tests.close() net = yaml.safe_load(json.dumps(response['net'])) net = {'l0': net['Input3'], 'l1': net['Regularization']} net['l0']['connection']['output'].append('l1') inp = data(net['l0'], '', 'l0')['l0'] net = regularization(net['l1'], [inp], 'l1') model = Model(inp, net['l1']) self.assertEqual(model.layers[1].__class__.__name__, 'ActivityRegularization')
|