當前位置: 首頁>>代碼示例>>Python>>正文


Python initializers.glorot_normal方法代碼示例

本文整理匯總了Python中keras.initializers.glorot_normal方法的典型用法代碼示例。如果您正苦於以下問題:Python initializers.glorot_normal方法的具體用法?Python initializers.glorot_normal怎麽用?Python initializers.glorot_normal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keras.initializers的用法示例。


在下文中一共展示了initializers.glorot_normal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def build(self, input_shape):
        n_weight_rows = input_shape[2]
        self.kernel_1 = self.add_weight(name='kernel_1',
                                        shape=(n_weight_rows, self.output_dim),
                                        initializer=glorot_normal(),
                                        trainable=True)
        self.kernel_2 = self.add_weight(name='kernel_2',
                                        shape=(n_weight_rows, self.output_dim),
                                        initializer=glorot_normal(),
                                        trainable=True)
        self.bias_1 = self.add_weight(name='bias_1',
                                      shape=(self.output_dim,),
                                      initializer=glorot_normal(),
                                      trainable=True)
        self.bias_2 = self.add_weight(name='bias_2',
                                      shape=(self.output_dim,),
                                      initializer=glorot_normal(),
                                      trainable=True)
        super(GaussianLayer, self).build(input_shape) 
開發者ID:arrigonialberto86,項目名稱:deepar,代碼行數:21,代碼來源:layers.py

示例2: test_glorot_normal

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def test_glorot_normal(tensor_shape):
    fan_in, fan_out = initializers._compute_fans(tensor_shape)
    scale = np.sqrt(2. / (fan_in + fan_out))
    _runner(initializers.glorot_normal(), tensor_shape,
            target_mean=0., target_std=None, target_max=2 * scale) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:7,代碼來源:initializers_test.py

示例3: get_model

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [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

示例4: _build_fn_regressor

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [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

示例5: run_initialization_matching_optimization_0

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def run_initialization_matching_optimization_0(build_fn):
    optimizer = DummyOptPro(iterations=1)
    optimizer.forge_experiment(
        model_initializer=KerasClassifier,
        model_init_params=dict(build_fn=build_fn),
        model_extra_params=dict(epochs=1, batch_size=128, verbose=0),
    )
    optimizer.go()
    return optimizer


#################### `glorot_normal` (`VarianceScaling`) #################### 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:14,代碼來源:test_keras.py

示例6: _build_fn_glorot_normal_0

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def _build_fn_glorot_normal_0(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 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:11,代碼來源:test_keras.py

示例7: _build_fn_glorot_normal_1

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [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

示例8: _build_fn_categorical_0

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [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

示例9: _build_fn_categorical_2

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def _build_fn_categorical_2(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

示例10: _build_fn_categorical_3

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def _build_fn_categorical_3(input_shape):  # `Categorical(["glorot_normal", orthogonal(gain=1)])`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=Categorical(["glorot_normal", orthogonal(gain=1)])),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:11,代碼來源:test_keras.py

示例11: _build_fn_categorical_4

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def _build_fn_categorical_4(input_shape):  # `Categorical(["glorot_normal", Orthogonal(gain=1)])`
    model = Sequential(
        [
            Dense(Integer(50, 100), input_shape=input_shape),
            Dense(1, kernel_initializer=Categorical(["glorot_normal", Orthogonal(gain=1)])),
        ]
    )
    model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
    return model 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:11,代碼來源:test_keras.py

示例12: test_in_space_inclusive_callable

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def test_in_space_inclusive_callable(self, old_opt, new_opt):
        assert in_similar_experiment_ids(old_opt, new_opt)

    ##################################################
    # `glorot_normal` (`VarianceScaling`)
    ################################################## 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:8,代碼來源:test_keras.py

示例13: test_in_categorical_0

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def test_in_categorical_0(self, old_opt):  # `Categorical(["glorot_normal", "o"])`
        assert in_similar_experiment_ids(old_opt, self.opt_g_0) 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:4,代碼來源:test_keras.py

示例14: test_in_categorical_2

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def test_in_categorical_2(self, old_opt):  # `Categorical([glorot_normal(), O()])`
        assert in_similar_experiment_ids(old_opt, self.opt_g_2) 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:4,代碼來源:test_keras.py

示例15: test_in_categorical_3

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import glorot_normal [as 別名]
def test_in_categorical_3(self, old_opt):  # `Categorical(["glorot_normal", o(gain=1)])`
        assert in_similar_experiment_ids(old_opt, self.opt_g_3) 
開發者ID:HunterMcGushion,項目名稱:hyperparameter_hunter,代碼行數:4,代碼來源:test_keras.py


注:本文中的keras.initializers.glorot_normal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。