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


Python layers.Average方法代碼示例

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


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

示例1: test_merge_average

# 需要導入模塊: from keras import layers [as 別名]
# 或者: from keras.layers import Average [as 別名]
def test_merge_average():
    i1 = layers.Input(shape=(4, 5))
    i2 = layers.Input(shape=(4, 5))
    o = layers.average([i1, i2])
    assert o._keras_shape == (None, 4, 5)
    model = models.Model([i1, i2], o)

    avg_layer = layers.Average()
    o2 = avg_layer([i1, i2])
    assert avg_layer.output_shape == (None, 4, 5)

    x1 = np.random.random((2, 4, 5))
    x2 = np.random.random((2, 4, 5))
    out = model.predict([x1, x2])
    assert out.shape == (2, 4, 5)
    assert_allclose(out, 0.5 * (x1 + x2), atol=1e-4) 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:18,代碼來源:merge_test.py

示例2: ensemble

# 需要導入模塊: from keras import layers [as 別名]
# 或者: from keras.layers import Average [as 別名]
def ensemble(models,model_input):
    outputs = [model(model_input) for model in models]
    y = Average()(outputs)

    model = Model(model_input, y, name='ensemble')

    return model 
開發者ID:GateNLP,項目名稱:semeval2019-hyperpartisan-bertha-von-suttner,代碼行數:9,代碼來源:ensemble_pred.py

示例3: create_multi_input_model_from

# 需要導入模塊: from keras import layers [as 別名]
# 或者: from keras.layers import Average [as 別名]
def create_multi_input_model_from(layer1, layer2):
    input_1 = Input(shape=(data_dim,))
    input_2 = Input(shape=(data_dim,))
    out1 = layer1(input_1)
    out2 = layer2(input_2)
    out = Average()([out1, out2])
    model = Model([input_1, input_2], out)
    model.add_loss(K.mean(out2))
    model.add_loss(1)
    model.add_loss(1)
    return model 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:13,代碼來源:regularizers_test.py


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