当前位置: 首页>>代码示例>>Python>>正文


Python initializers.orthogonal方法代码示例

本文整理汇总了Python中keras.initializers.orthogonal方法的典型用法代码示例。如果您正苦于以下问题:Python initializers.orthogonal方法的具体用法?Python initializers.orthogonal怎么用?Python initializers.orthogonal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras.initializers的用法示例。


在下文中一共展示了initializers.orthogonal方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_orthogonal

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def test_orthogonal(tensor_shape):
    _runner(initializers.orthogonal(), tensor_shape,
            target_mean=0.) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:5,代码来源:initializers_test.py

示例2: get_model

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def get_model(embed_weights):
    input_layer = Input(shape=(MAX_LEN, ), name='input')
    # 1. embedding layer
    # get embedding weights
    print('load pre-trained embedding weights ......')
    input_dim = embed_weights.shape[0]
    output_dim = embed_weights.shape[1]
    x = Embedding(
        input_dim=input_dim,
        output_dim=output_dim,
        weights=[embed_weights],
        trainable=False,
        name='embedding'
    )(input_layer)
    # clean up
    del embed_weights, input_dim, output_dim
    gc.collect()
    # 2. dropout
    x = SpatialDropout1D(rate=SPATIAL_DROPOUT)(x)
    # 3. bidirectional lstm
    x = Bidirectional(
        layer=CuDNNLSTM(RNN_UNITS, return_sequences=True,
                        kernel_initializer=glorot_normal(seed=1029),
                        recurrent_initializer=orthogonal(gain=1.0, seed=1029)),
        name='bidirectional_lstm')(x)
    # 4. capsule layer
    capsul = Capsule(num_capsule=10, dim_capsule=10, routings=4, share_weights=True)(x) # noqa
    capsul = Flatten()(capsul)
    capsul = DropConnect(Dense(32, activation="relu"), prob=0.01)(capsul)

    # 5. attention later
    atten = Attention(step_dim=MAX_LEN, name='attention')(x)
    atten = DropConnect(Dense(16, activation="relu"), prob=0.05)(atten)
    x = Concatenate(axis=-1)([capsul, atten])

    # 6. output (sigmoid)
    output_layer = Dense(units=1, activation='sigmoid', name='output')(x)
    model = Model(inputs=input_layer, outputs=output_layer)
    # compile model
    model.compile(loss='binary_crossentropy', optimizer='adam')
    return model 
开发者ID:KevinLiao159,项目名称:Quora,代码行数:43,代码来源:submission_v50.py

示例3: _build_fn_regressor

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_regressor(input_shape):
    model = Sequential(
        [
            Dense(100, activation="relu", input_shape=input_shape),
            Dense(Integer(40, 60), activation="relu", kernel_initializer="glorot_normal"),
            Dropout(Real(0.2, 0.7)),
            Dense(1, activation=Categorical(["relu", "sigmoid"]), kernel_initializer="orthogonal"),
        ]
    )
    model.compile(
        optimizer=Categorical(["adam", "rmsprop"]),
        loss="mean_absolute_error",
        metrics=["mean_absolute_error"],
    )
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:17,代码来源:test_keras.py

示例4: _build_fn_glorot_normal_1

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_glorot_normal_1(input_shape):  # `"glorot_normal"`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer="glorot_normal"),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model


#################### `orthogonal` - Excluding default (`Initializer`) #################### 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:14,代码来源:test_keras.py

示例5: _build_fn_orthogonal_e_0

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_e_0(input_shape):  # `orthogonal(gain=Real(0.3, 0.9))`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=orthogonal(gain=Real(0.3, 0.9))),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例6: _build_fn_orthogonal_e_2

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_e_2(input_shape):  # `orthogonal(gain=0.5)`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=orthogonal(gain=0.5)),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例7: _build_fn_orthogonal_e_3

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_e_3(input_shape):  # `Orthogonal(gain=0.5)`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=Orthogonal(gain=0.5)),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model


#################### `orthogonal` - Including default (`Initializer`) #################### 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:14,代码来源:test_keras.py

示例8: _build_fn_orthogonal_i_1

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_i_1(input_shape):  # `orthogonal()`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=orthogonal()),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例9: _build_fn_orthogonal_i_3

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_i_3(input_shape):  # `orthogonal(gain=1.0)`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=orthogonal(gain=1.0)),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例10: _build_fn_orthogonal_i_5

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_orthogonal_i_5(input_shape):  # `orthogonal(gain=Real(0.6, 1.6))`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=orthogonal(gain=Real(0.6, 1.6))),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例11: _build_fn_categorical_0

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_categorical_0(input_shape):  # `Categorical(["glorot_normal", "orthogonal"])`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=Categorical(["glorot_normal", "orthogonal"])),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例12: _build_fn_categorical_1

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def _build_fn_categorical_1(input_shape):  # `Categorical([glorot_normal(), orthogonal()])`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=Categorical([glorot_normal(), orthogonal()])),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:11,代码来源:test_keras.py

示例13: test_in_custom_arg_callable

# 需要导入模块: from keras import initializers [as 别名]
# 或者: from keras.initializers import orthogonal [as 别名]
def test_in_custom_arg_callable(self, old_opt, new_opt):
        assert in_similar_experiment_ids(old_opt, new_opt)

    ##################################################
    # `orthogonal` - Including default (`Initializer`)
    ################################################## 
开发者ID:HunterMcGushion,项目名称:hyperparameter_hunter,代码行数:8,代码来源:test_keras.py


注:本文中的keras.initializers.orthogonal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。