Python keras.layers.Average() Examples
The following are 15
code examples of keras.layers.Average().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
keras.layers
, or try the search function
.

Example #1
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #2
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #3
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #4
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #5
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #6
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: merge_test.py License: MIT License | 6 votes |
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)
Example #7
Source Project: semeval2019-hyperpartisan-bertha-von-suttner Author: GateNLP File: ensemble_pred.py License: Apache License 2.0 | 5 votes |
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
Example #8
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #9
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #10
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #11
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #12
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #13
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #14
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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
Example #15
Source Project: DeepLearning_Wavelet-LSTM Author: hello-sea File: regularizers_test.py License: MIT License | 5 votes |
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