Python keras.initializations.normal() Examples
The following are 26
code examples of keras.initializations.normal().
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.initializations
, or try the search function
.
Example #1
Source File: vaegan_cifar.py From MachineLearning with Apache License 2.0 | 6 votes |
def generator(batch_size, gf_dim, ch, rows, cols): model = Sequential() model.add( Dense(gf_dim * 8 * rows[0] * cols[0], batch_input_shape=(batch_size, z_dim), name="g_h0_lin", init=normal)) model.add(Reshape((rows[0], cols[0], gf_dim * 8))) model.add(BN(mode=2, axis=3, name="g_bn0", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(gf_dim * 4, 5, 5, output_shape=(batch_size, rows[1], cols[1], gf_dim * 4), subsample=(2, 2), name="g_h1", border_mode="same", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn1", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(gf_dim * 2, 5, 5, output_shape=(batch_size, rows[2], cols[2], gf_dim * 2), subsample=(2, 2), name="g_h2", border_mode="same", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn2", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(ch, 5, 5, output_shape=(batch_size, rows[3], cols[3], ch), subsample=(2, 2), name="g_h3", border_mode="same", init=normal)) model.add(Activation("tanh")) return model
Example #2
Source File: vaegan_cifar.py From MachineLearning with Apache License 2.0 | 6 votes |
def encoder(batch_size, df_dim, ch, rows, cols): model = Sequential() X = Input(batch_shape=(batch_size, rows[-1], cols[-1], ch)) model = Convolution2D(df_dim, 5, 5, subsample=(2, 2), border_mode="same", name="e_h0_conv", dim_ordering="tf", init=normal)(X) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 2, 5, 5, subsample=(2, 2), border_mode="same", name="e_h1_conv", dim_ordering="tf")(model) model = BN(mode=2, axis=3, name="e_bn1", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 4, 5, 5, subsample=(2, 2), name="e_h2_conv", border_mode="same", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="e_bn2", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Flatten()(model) mean = Dense(z_dim, name="e_h3_lin", init=normal)(model) logsigma = Dense(z_dim, name="e_h4_lin", activation="tanh", init=normal)(model) meansigma = Model([X], [mean, logsigma]) return meansigma
Example #3
Source File: vaegan_cifar.py From MachineLearning with Apache License 2.0 | 6 votes |
def discriminator(batch_size, df_dim, ch, rows, cols): X = Input(batch_shape=(batch_size, rows[-1], cols[-1], ch)) model = Convolution2D(df_dim, 5, 5, subsample=(2, 2), border_mode="same", name="d_h0_conv", dim_ordering="tf", init=normal)(X) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 2, 5, 5, subsample=(2, 2), border_mode="same", name="d_h1_conv", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="d_bn1", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 4, 5, 5, subsample=(2, 2), border_mode="same", name="d_h2_conv", dim_ordering="tf", init=normal)(model) dec = BN(mode=2, axis=3, name="d_bn3", gamma_init=mean_normal, epsilon=1e-5)(model) dec = LeakyReLU(.2)(dec) dec = Flatten()(dec) dec = Dense(1, name="d_h3_lin", init=normal)(dec) output = Model([X], [dec, model]) return output
Example #4
Source File: vaegan_svhn.py From MachineLearning with Apache License 2.0 | 6 votes |
def generator(batch_size, gf_dim, ch, rows, cols): model = Sequential() model.add( Dense(gf_dim * 8 * rows[0] * cols[0], batch_input_shape=(batch_size, z_dim), name="g_h0_lin", init=normal)) model.add(Reshape((rows[0], cols[0], gf_dim * 8))) model.add(BN(mode=2, axis=3, name="g_bn0", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(gf_dim * 4, 5, 5, output_shape=(batch_size, rows[1], cols[1], gf_dim * 4), subsample=(2, 2), name="g_h1", border_mode="same", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn1", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(gf_dim * 2, 5, 5, output_shape=(batch_size, rows[2], cols[2], gf_dim * 2), subsample=(2, 2), name="g_h2", border_mode="same", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn2", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconvolution2D(ch, 5, 5, output_shape=(batch_size, rows[3], cols[3], ch), subsample=(2, 2), name="g_h3", border_mode="same", init=normal)) model.add(Activation("tanh")) return model
Example #5
Source File: vaegan_svhn.py From MachineLearning with Apache License 2.0 | 6 votes |
def encoder(batch_size, df_dim, ch, rows, cols): model = Sequential() X = Input(batch_shape=(batch_size, rows[-1], cols[-1], ch)) model = Convolution2D(df_dim, 5, 5, subsample=(2, 2), border_mode="same", name="e_h0_conv", dim_ordering="tf", init=normal)(X) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 2, 5, 5, subsample=(2, 2), border_mode="same", name="e_h1_conv", dim_ordering="tf")(model) model = BN(mode=2, axis=3, name="e_bn1", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 4, 5, 5, subsample=(2, 2), name="e_h2_conv", border_mode="same", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="e_bn2", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Flatten()(model) mean = Dense(z_dim, name="e_h3_lin", init=normal)(model) logsigma = Dense(z_dim, name="e_h4_lin", activation="tanh", init=normal)(model) meansigma = Model([X], [mean, logsigma]) return meansigma
Example #6
Source File: vaegan_svhn.py From MachineLearning with Apache License 2.0 | 6 votes |
def discriminator(batch_size, df_dim, ch, rows, cols): X = Input(batch_shape=(batch_size, rows[-1], cols[-1], ch)) model = Convolution2D(df_dim, 5, 5, subsample=(2, 2), border_mode="same", name="d_h0_conv", dim_ordering="tf", init=normal)(X) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 2, 5, 5, subsample=(2, 2), border_mode="same", name="d_h1_conv", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="d_bn1", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim * 4, 5, 5, subsample=(2, 2), border_mode="same", name="d_h2_conv", dim_ordering="tf", init=normal)(model) dec = BN(mode=2, axis=3, name="d_bn3", gamma_init=mean_normal, epsilon=1e-5)(model) dec = LeakyReLU(.2)(dec) dec = Flatten()(dec) dec = Dense(1, name="d_h3_lin", init=normal)(dec) output = Model([X], [dec, model]) return output
Example #7
Source File: autoencoder.py From research with BSD 3-Clause "New" or "Revised" License | 6 votes |
def generator(batch_size, gf_dim, ch, rows, cols): model = Sequential() model.add(Dense(gf_dim*8*rows[0]*cols[0], batch_input_shape=(batch_size, z_dim), name="g_h0_lin", init=normal)) model.add(Reshape((rows[0], cols[0], gf_dim*8))) model.add(BN(mode=2, axis=3, name="g_bn0", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconv2D(gf_dim*4, 5, 5, subsample=(2, 2), name="g_h1", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn1", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconv2D(gf_dim*2, 5, 5, subsample=(2, 2), name="g_h2", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn2", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconv2D(gf_dim, 5, 5, subsample=(2, 2), name="g_h3", init=normal)) model.add(BN(mode=2, axis=3, name="g_bn3", gamma_init=mean_normal, epsilon=1e-5)) model.add(Activation("relu")) model.add(Deconv2D(ch, 5, 5, subsample=(2, 2), name="g_h4", init=normal)) model.add(Activation("tanh")) return model
Example #8
Source File: cppn.py From cppn-keras with MIT License | 5 votes |
def my_init(shape, name=None): return initializations.normal(shape, scale=1.2, name=name)
Example #9
Source File: vaegan_cifar.py From MachineLearning with Apache License 2.0 | 5 votes |
def mean_normal(shape, mean=1., scale=0.02, name=None): return K.variable(np.random.normal(loc=mean, scale=scale, size=shape), name=name)
Example #10
Source File: audiounet.py From audio-super-res with MIT License | 5 votes |
def normal_init(shape, dim_ordering='tf', name=None): return normal(shape, scale=1e-3, name=name, dim_ordering=dim_ordering)
Example #11
Source File: audiotfilm.py From audio-super-res with MIT License | 5 votes |
def normal_init(shape, dim_ordering='tf', name=None): return normal(shape, scale=1e-3, name=name, dim_ordering=dim_ordering)
Example #12
Source File: dnn.py From audio-super-res with MIT License | 5 votes |
def normal_init(shape, dim_ordering='tf', name=None): return normal(shape, scale=0.0000001, name=name, dim_ordering=dim_ordering)
Example #13
Source File: LUNA_unet.py From Luna2016-Lung-Nodule-Detection with MIT License | 5 votes |
def gaussian_init(shape, name=None, dim_ordering=None): return initializations.normal(shape, scale=0.001, name=name, dim_ordering=dim_ordering)
Example #14
Source File: transition.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def cleanup(data): X = data[0] sh = X.shape X = X.reshape((-1, 3, 160, 320)) X = np.asarray([cv2.resize(x.transpose(1, 2, 0), (160, 80)) for x in X]) X = X/127.5 - 1. X = X.reshape((sh[0], (time+out_leng)*4, 80, 160, 3)) Z = np.random.normal(0, 1, (X.shape[0], z_dim)) return Z, X[:, ::4]
Example #15
Source File: transition.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def mean_normal(shape, mean=1., scale=0.02, name=None): return K.variable(np.random.normal(loc=mean, scale=scale, size=shape), name=name)
Example #16
Source File: autoencoder.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def encoder(batch_size, df_dim, ch, rows, cols): model = Sequential() X = Input(batch_shape=(batch_size, rows[-1], cols[-1], ch)) model = Convolution2D(df_dim, 5, 5, subsample=(2, 2), border_mode="same", name="e_h0_conv", dim_ordering="tf", init=normal)(X) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim*2, 5, 5, subsample=(2, 2), border_mode="same", name="e_h1_conv", dim_ordering="tf")(model) model = BN(mode=2, axis=3, name="e_bn1", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim*4, 5, 5, subsample=(2, 2), name="e_h2_conv", border_mode="same", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="e_bn2", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Convolution2D(df_dim*8, 5, 5, subsample=(2, 2), border_mode="same", name="e_h3_conv", dim_ordering="tf", init=normal)(model) model = BN(mode=2, axis=3, name="e_bn3", gamma_init=mean_normal, epsilon=1e-5)(model) model = LeakyReLU(.2)(model) model = Flatten()(model) mean = Dense(z_dim, name="e_h3_lin", init=normal)(model) logsigma = Dense(z_dim, name="e_h4_lin", activation="tanh", init=normal)(model) meansigma = Model([X], [mean, logsigma]) return meansigma
Example #17
Source File: autoencoder.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def cleanup(data): X = data[0][:64, -1] X = np.asarray([cv2.resize(x.transpose(1, 2, 0), (160, 80)) for x in X]) X = X/127.5 - 1. Z = np.random.normal(0, 1, (X.shape[0], z_dim)) return Z, X
Example #18
Source File: autoencoder.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def mean_normal(shape, mean=1., scale=0.02, name=None): return K.variable(np.random.normal(loc=mean, scale=scale, size=shape), name=name)
Example #19
Source File: conditional.py From research with BSD 3-Clause "New" or "Revised" License | 5 votes |
def mean_normal(shape, mean=1., scale=0.02, name=None): return K.variable(np.random.normal(loc=mean, scale=scale, size=shape), name=name)
Example #20
Source File: reinforcement.py From detection-2016-nipsws with MIT License | 5 votes |
def get_q_network(weights_path): model = Sequential() model.add(Dense(1024, init=lambda shape, name: normal(shape, scale=0.01, name=name), input_shape=(25112,))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(1024, init=lambda shape, name: normal(shape, scale=0.01, name=name))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(6, init=lambda shape, name: normal(shape, scale=0.01, name=name))) model.add(Activation('linear')) adam = Adam(lr=1e-6) model.compile(loss='mse', optimizer=adam) if weights_path != "0": model.load_weights(weights_path) return model
Example #21
Source File: model.py From neural-style-keras with MIT License | 5 votes |
def weights_init(shape, name=None, dim_ordering=None): return normal(shape, scale=0.01, name=name)
Example #22
Source File: NeuMF.py From neural_collaborative_filtering with Apache License 2.0 | 5 votes |
def init_normal(shape, name=None): return initializations.normal(shape, scale=0.01, name=name)
Example #23
Source File: GMF.py From neural_collaborative_filtering with Apache License 2.0 | 5 votes |
def init_normal(shape, name=None): return initializations.normal(shape, scale=0.01, name=name)
Example #24
Source File: MLP.py From neural_collaborative_filtering with Apache License 2.0 | 5 votes |
def init_normal(shape, name=None): return initializations.normal(shape, scale=0.01, name=name)
Example #25
Source File: vaegan_svhn.py From MachineLearning with Apache License 2.0 | 5 votes |
def fetch_next_batch(s): z = np.random.normal(0., 1., (batch_size, z_dim)) # normal dist for GAN x = s.train.next_batch(batch_size) return z, x[0]
Example #26
Source File: vaegan_cifar.py From MachineLearning with Apache License 2.0 | 5 votes |
def fetch_next_batch(cifar): z = np.random.normal(0., 1., (batch_size, z_dim)) # normal dist for GAN x = cifar.train.next_batch(batch_size) return z, x[0]