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


Python initializers._compute_fans方法代碼示例

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


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

示例1: __call__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import _compute_fans [as 別名]
def __call__(self, shape, dtype=None):

        if self.nb_filters is not None:
            kernel_shape = tuple(self.kernel_size) + (int(self.input_dim), self.nb_filters)
        else:
            kernel_shape = (int(self.input_dim), self.kernel_size[-1])

        fan_in, fan_out = initializers._compute_fans(
            tuple(self.kernel_size) + (self.input_dim, self.nb_filters)
        )

        if self.criterion == 'glorot':
            s = 1. / (fan_in + fan_out)
        elif self.criterion == 'he':
            s = 1. / fan_in
        else:
            raise ValueError('Invalid criterion: ' + self.criterion)
        rng = RandomState(self.seed)
        modulus = rng.rayleigh(scale=s, size=kernel_shape)
        phase = rng.uniform(low=-np.pi, high=np.pi, size=kernel_shape)
        weight_real = modulus * np.cos(phase)
        weight_imag = modulus * np.sin(phase)
        weight = np.concatenate([weight_real, weight_imag], axis=-1)

        return weight 
開發者ID:ChihebTrabelsi,項目名稱:deep_complex_networks,代碼行數:27,代碼來源:init.py

示例2: test_lecun_uniform

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

示例3: test_glorot_uniform

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

示例4: test_he_uniform

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

示例5: test_glorot_normal

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

示例6: test_he_normal

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


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