这篇教程Python layers.LocallyConnected1D方法代码示例写得很实用,希望能帮到您。
本文整理汇总了Python中keras.layers.LocallyConnected1D方法的典型用法代码示例。如果您正苦于以下问题:Python layers.LocallyConnected1D方法的具体用法?Python layers.LocallyConnected1D怎么用?Python layers.LocallyConnected1D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块keras.layers 的用法示例。 在下文中一共展示了layers.LocallyConnected1D方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。 示例1: test_keras_import# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import LocallyConnected1D [as 别名]def test_keras_import(self): # Conv 1D model = Sequential() model.add(LocallyConnected1D(32, 3, kernel_regularizer=regularizers.l2(0.01), bias_regularizer=regularizers.l2(0.01), activity_regularizer=regularizers.l2(0.01), kernel_constraint='max_norm', bias_constraint='max_norm', activation='relu', input_shape=(16, 10))) model.build() self.keras_param_test(model, 1, 12) # Conv 2D model = Sequential() model.add(LocallyConnected2D(32, (3, 3), kernel_regularizer=regularizers.l2(0.01), bias_regularizer=regularizers.l2(0.01), activity_regularizer=regularizers.l2(0.01), kernel_constraint='max_norm', bias_constraint='max_norm', activation='relu', input_shape=(16, 16, 10))) model.build() self.keras_param_test(model, 1, 14)# ********** Recurrent Layers **********
示例2: localconv1d# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import LocallyConnected1D [as 别名]def localconv1d(x, filters, kernel_size, strides=1, use_bias=True, name=None): """LocallyConnected1D possibly wrapped by a TimeDistributed layer.""" f = LocallyConnected1D(filters, kernel_size, strides=strides, use_bias=use_bias, name=name) return TimeDistributed(f, name=name)(x) if K.ndim(x) == 4 else f(x)
开发者ID:dluvizon,项目名称:deephar,代码行数:8,代码来源:layers.py
示例3: add_conv_layer# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import LocallyConnected1D [as 别名]def add_conv_layer(model, layer_params, input_dim=None, locally_connected=False): if len(layer_params) == 3: # 1D convolution filters = layer_params[0] filter_len = layer_params[1] stride = layer_params[2] if locally_connected: if input_dim: model.add(LocallyConnected1D(filters, filter_len, strides=stride, input_shape=(input_dim, 1))) else: model.add(LocallyConnected1D(filters, filter_len, strides=stride)) else: if input_dim: model.add(Conv1D(filters, filter_len, strides=stride, input_shape=(input_dim, 1))) else: model.add(Conv1D(filters, filter_len, strides=stride)) elif len(layer_params) == 5: # 2D convolution filters = layer_params[0] filter_len = (layer_params[1], layer_params[2]) stride = (layer_params[3], layer_params[4]) if locally_connected: if input_dim: model.add(LocallyConnected2D(filters, filter_len, strides=stride, input_shape=(input_dim, 1))) else: model.add(LocallyConnected2D(filters, filter_len, strides=stride)) else: if input_dim: model.add(Conv2D(filters, filter_len, strides=stride, input_shape=(input_dim, 1))) else: model.add(Conv2D(filters, filter_len, strides=stride)) return model
示例4: locally_connected# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import LocallyConnected1D [as 别名]def locally_connected(layer, layer_in, layerId, tensor=True): localMap = { '1D': LocallyConnected1D, '2D': LocallyConnected2D, } out = {} kernel_initializer = layer['params']['kernel_initializer'] bias_initializer = layer['params']['bias_initializer'] filters = layer['params']['filters'] kernel_regularizer = regularizerMap[layer['params']['kernel_regularizer']] bias_regularizer = regularizerMap[layer['params']['bias_regularizer']] activity_regularizer = regularizerMap[layer['params'] ['activity_regularizer']] kernel_constraint = constraintMap[layer['params']['kernel_constraint']] bias_constraint = constraintMap[layer['params']['bias_constraint']] use_bias = layer['params']['use_bias'] layer_type = layer['params']['layer_type'] if (layer_type == '1D'): strides = layer['params']['stride_w'] kernel = layer['params']['kernel_w'] else: strides = (layer['params']['stride_h'], layer['params']['stride_w']) kernel = (layer['params']['kernel_h'], layer['params']['kernel_w']) out[layerId] = localMap[layer_type](filters, kernel, strides=strides, padding='valid', kernel_initializer=kernel_initializer, bias_initializer=bias_initializer, kernel_regularizer=kernel_regularizer, bias_regularizer=bias_regularizer, activity_regularizer=activity_regularizer, use_bias=use_bias, bias_constraint=bias_constraint, kernel_constraint=kernel_constraint) if tensor: out[layerId] = out[layerId](*layer_in) return out# ********** Recurrent Layers **********
示例5: test_keras_export# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import LocallyConnected1D [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['Input'], 'l1': net['Input2'], 'l3': net['LocallyConnected']} # LocallyConnected 1D net['l1']['connection']['output'].append('l3') net['l3']['connection']['input'] = ['l1'] net['l3']['params']['layer_type'] = '1D' inp = data(net['l1'], '', 'l1')['l1'] temp = locally_connected(net['l3'], [inp], 'l3') model = Model(inp, temp['l3']) self.assertEqual(model.layers[1].__class__.__name__, 'LocallyConnected1D') # LocallyConnected 2D net['l0']['connection']['output'].append('l0') net['l0']['shape']['output'] = [3, 10, 10] net['l3']['connection']['input'] = ['l0'] net['l3']['params']['layer_type'] = '2D' inp = data(net['l0'], '', 'l0')['l0'] temp = locally_connected(net['l3'], [inp], 'l3') model = Model(inp, temp['l3']) self.assertEqual(model.layers[1].__class__.__name__, 'LocallyConnected2D')# ********** Recurrent Layers Test **********
注:本文中的keras.layers.LocallyConnected1D方法 Python layers.SpatialDropout3D方法代码示例 Python layers.GlobalAveragePooling3D方法代码示例 |