Python tensorflow.contrib.layers.conv2d_transpose() Examples
The following are 22
code examples of tensorflow.contrib.layers.conv2d_transpose().
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
tensorflow.contrib.layers
, or try the search function
.
Example #1
Source File: autoencoder.py From TensorFlow-World with MIT License | 6 votes |
def autoencoder(inputs): # encoder # 32 x 32 x 1 -> 16 x 16 x 32 # 16 x 16 x 32 -> 8 x 8 x 16 # 8 x 8 x 16 -> 2 x 2 x 8 net = lays.conv2d(inputs, 32, [5, 5], stride=2, padding='SAME') net = lays.conv2d(net, 16, [5, 5], stride=2, padding='SAME') net = lays.conv2d(net, 8, [5, 5], stride=4, padding='SAME') # decoder # 2 x 2 x 8 -> 8 x 8 x 16 # 8 x 8 x 16 -> 16 x 16 x 32 # 16 x 16 x 32 -> 32 x 32 x 1 net = lays.conv2d_transpose(net, 16, [5, 5], stride=4, padding='SAME') net = lays.conv2d_transpose(net, 32, [5, 5], stride=2, padding='SAME') net = lays.conv2d_transpose(net, 1, [5, 5], stride=2, padding='SAME', activation_fn=tf.nn.tanh) return net # read MNIST dataset
Example #2
Source File: ops.py From DCGAN-Tensorflow with MIT License | 6 votes |
def deconv2d(input, deconv_info, is_train, name="deconv2d", stddev=0.02,activation_fn='relu'): with tf.variable_scope(name): output_shape = deconv_info[0] k = deconv_info[1] s = deconv_info[2] deconv = layers.conv2d_transpose(input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), kernel_size=[k, k], stride=[s, s], padding='VALID') if activation_fn == 'relu': deconv = tf.nn.relu(deconv) bn = tf.contrib.layers.batch_norm(deconv, center=True, scale=True, decay=0.9, is_training=is_train, updates_collections=None) elif activation_fn == 'tanh': deconv = tf.nn.tanh(deconv) return deconv
Example #3
Source File: utils.py From TensorFlow-VAE-GAN-DRAW with Apache License 2.0 | 6 votes |
def decoder(input_tensor): '''Create decoder network. If input tensor is provided then decodes it, otherwise samples from a sampled vector. Args: input_tensor: a batch of vectors to decode Returns: A tensor that expresses the decoder network ''' net = tf.expand_dims(input_tensor, 1) net = tf.expand_dims(net, 1) net = layers.conv2d_transpose(net, 128, 3, padding='VALID') net = layers.conv2d_transpose(net, 64, 5, padding='VALID') net = layers.conv2d_transpose(net, 32, 5, stride=2) net = layers.conv2d_transpose( net, 1, 5, stride=2, activation_fn=tf.nn.sigmoid) net = layers.flatten(net) return net
Example #4
Source File: ops.py From demo2program with MIT License | 6 votes |
def deconv2d(input, deconv_info, is_train, name="deconv2d", info=False, stddev=0.01, activation_fn=tf.nn.relu, batch_norm=True): with tf.variable_scope(name): output_shape = deconv_info[0] k = deconv_info[1] s = deconv_info[2] _ = layers.conv2d_transpose( input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), kernel_size=[k, k], stride=[s, s], padding='SAME' ) _ = bn_act(_, is_train, batch_norm=batch_norm, activation_fn=activation_fn) if info: log.info('{} {}'.format(name, _)) return _
Example #5
Source File: generator_conv.py From VAE-GAN with MIT License | 6 votes |
def __call__(self, i): with tf.variable_scope(self.name): if self.reuse: tf.get_variable_scope().reuse_variables() else: assert tf.get_variable_scope().reuse is False self.reuse = True g = tcl.fully_connected(i, self.size * self.size * 1024, activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm) g = tf.reshape(g, (-1, self.size, self.size, 1024)) # size g = tcl.conv2d_transpose(g, 512, 3, stride=2, # size*2 activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) g = tcl.conv2d_transpose(g, 256, 3, stride=2, # size*4 activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) g = tcl.conv2d_transpose(g, 128, 3, stride=2, # size*8 activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) g = tcl.conv2d_transpose(g, self.channel, 3, stride=2, # size*16 activation_fn=tf.nn.sigmoid, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) return g return x
Example #6
Source File: ops.py From Multiview2Novelview with MIT License | 6 votes |
def deconv2d(input, deconv_info, is_train, name="deconv2d", info=False, stddev=0.01, activation_fn=tf.nn.relu, norm='batch'): with tf.variable_scope(name): output_shape = deconv_info[0] k = deconv_info[1] s = deconv_info[2] _ = layers.conv2d_transpose( input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), kernel_size=[k, k], stride=[s, s], padding='SAME' ) _ = bn_act(_, is_train, norm=norm, activation_fn=activation_fn) if info: log.info('{} {}'.format(name, _.get_shape().as_list())) return _
Example #7
Source File: ops.py From Generative-Latent-Optimization-Tensorflow with MIT License | 5 votes |
def deconv2d(input, deconv_info, is_train, name="deconv2d", stddev=0.02, activation_fn=tf.nn.relu, batch_norm=True): with tf.variable_scope(name): output_shape = deconv_info[0] k = deconv_info[1] s = deconv_info[2] _ = layers.conv2d_transpose( input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), kernel_size=[k, k], stride=[s, s], padding='SAME' ) return bn_act(_, is_train, batch_norm=batch_norm, activation_fn=activation_fn)
Example #8
Source File: wgan_mnist.py From minimal_wgan with MIT License | 5 votes |
def generator(z): with tf.variable_scope('generator'): z = layers.fully_connected(z, num_outputs=4096) z = tf.reshape(z, [-1, 4, 4, 256]) z = layers.conv2d_transpose(z, num_outputs=128, kernel_size=5, stride=2) z = layers.conv2d_transpose(z, num_outputs=64, kernel_size=5, stride=2) z = layers.conv2d_transpose(z, num_outputs=1, kernel_size=5, stride=2, activation_fn=tf.nn.sigmoid) return z[:, 2:-2, 2:-2, :]
Example #9
Source File: ops.py From WGAN-GP-TensorFlow with MIT License | 5 votes |
def deconv2d(input, output_shape, is_train, info=False, k=3, s=2, stddev=0.01, activation_fn=tf.nn.relu, norm='batch', name='deconv2d'): with tf.variable_scope(name): _ = layers.conv2d_transpose( input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), activation_fn=None, kernel_size=[k, k], stride=[s, s], padding='SAME' ) _ = norm_and_act(_, is_train, norm=norm, activation_fn=activation_fn) if info: print_info(name, _.get_shape().as_list(), activation_fn) return _
Example #10
Source File: hyperparams_builder_test.py From aster with MIT License | 5 votes |
def test_default_arg_scope_has_conv2d_transpose_op(self): conv_hyperparams_text_proto = """ regularizer { l1_regularizer { } } initializer { truncated_normal_initializer { } } """ conv_hyperparams_proto = hyperparams_pb2.Hyperparams() text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto) scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True) self.assertTrue(self._get_scope_key(layers.conv2d_transpose) in scope)
Example #11
Source File: vae.py From TensorFlow-VAE-GAN-DRAW with Apache License 2.0 | 5 votes |
def __init__(self, hidden_size, batch_size, learning_rate): self.input_tensor = tf.placeholder( tf.float32, [None, 28 * 28]) with arg_scope([layers.conv2d, layers.conv2d_transpose], activation_fn=tf.nn.elu, normalizer_fn=layers.batch_norm, normalizer_params={'scale': True}): with tf.variable_scope("model") as scope: encoded = encoder(self.input_tensor, hidden_size * 2) mean = encoded[:, :hidden_size] stddev = tf.sqrt(tf.exp(encoded[:, hidden_size:])) epsilon = tf.random_normal([tf.shape(mean)[0], hidden_size]) input_sample = mean + epsilon * stddev output_tensor = decoder(input_sample) with tf.variable_scope("model", reuse=True) as scope: self.sampled_tensor = decoder(tf.random_normal( [batch_size, hidden_size])) vae_loss = self.__get_vae_cost(mean, stddev) rec_loss = self.__get_reconstruction_cost( output_tensor, self.input_tensor) loss = vae_loss + rec_loss self.train = layers.optimize_loss(loss, tf.contrib.framework.get_or_create_global_step( ), learning_rate=learning_rate, optimizer='Adam', update_ops=[]) self.sess = tf.Session() self.sess.run(tf.global_variables_initializer())
Example #12
Source File: gan.py From TensorFlow-VAE-GAN-DRAW with Apache License 2.0 | 5 votes |
def __init__(self, hidden_size, batch_size, learning_rate): self.input_tensor = tf.placeholder(tf.float32, [None, 28 * 28]) with arg_scope([layers.conv2d, layers.conv2d_transpose], activation_fn=concat_elu, normalizer_fn=layers.batch_norm, normalizer_params={'scale': True}): with tf.variable_scope("model"): D1 = discriminator(self.input_tensor) # positive examples D_params_num = len(tf.trainable_variables()) G = decoder(tf.random_normal([batch_size, hidden_size])) self.sampled_tensor = G with tf.variable_scope("model", reuse=True): D2 = discriminator(G) # generated examples D_loss = self.__get_discrinator_loss(D1, D2) G_loss = self.__get_generator_loss(D2) params = tf.trainable_variables() D_params = params[:D_params_num] G_params = params[D_params_num:] # train_discrimator = optimizer.minimize(loss=D_loss, var_list=D_params) # train_generator = optimizer.minimize(loss=G_loss, var_list=G_params) global_step = tf.contrib.framework.get_or_create_global_step() self.train_discrimator = layers.optimize_loss( D_loss, global_step, learning_rate / 10, 'Adam', variables=D_params, update_ops=[]) self.train_generator = layers.optimize_loss( G_loss, global_step, learning_rate, 'Adam', variables=G_params, update_ops=[]) self.sess = tf.Session() self.sess.run(tf.global_variables_initializer())
Example #13
Source File: op_handler_util_test.py From morph-net with Apache License 2.0 | 5 votes |
def testOpAssumptions(self): # Verify that op assumptions are true. For example, verify that specific # inputs are at expected indices. conv_transpose = layers.conv2d_transpose( self.batch_norm_op.outputs[0], num_outputs=8, kernel_size=3, scope='conv_transpose') layers.separable_conv2d( conv_transpose, num_outputs=9, kernel_size=3, scope='dwise_conv') layers.fully_connected(tf.zeros([1, 7]), 10, scope='fc') g = tf.get_default_graph() # Verify that FusedBatchNormV3 has gamma as inputs[1]. self.assertEqual('conv1/BatchNorm/gamma/read:0', self.batch_norm_op.inputs[1].name) # Verify that Conv2D has weights at expected index. index = op_handler_util.WEIGHTS_INDEX_DICT[self.conv_op.type] self.assertEqual('conv1/weights/read:0', self.conv_op.inputs[index].name) # Verify that Conv2DBackpropInput has weights at expected index. conv_transpose_op = g.get_operation_by_name( 'conv_transpose/conv2d_transpose') index = op_handler_util.WEIGHTS_INDEX_DICT[conv_transpose_op.type] self.assertEqual('conv_transpose/weights/read:0', conv_transpose_op.inputs[index].name) # Verify that DepthwiseConv2dNative has weights at expected index. depthwise_conv_op = g.get_operation_by_name( 'dwise_conv/separable_conv2d/depthwise') index = op_handler_util.WEIGHTS_INDEX_DICT[depthwise_conv_op.type] self.assertEqual('dwise_conv/depthwise_weights/read:0', depthwise_conv_op.inputs[index].name) # Verify that MatMul has weights at expected index. matmul_op = g.get_operation_by_name('fc/MatMul') index = op_handler_util.WEIGHTS_INDEX_DICT[matmul_op.type] self.assertEqual('fc/weights/read:0', matmul_op.inputs[index].name)
Example #14
Source File: cost_calculator_test.py From morph-net with Apache License 2.0 | 5 votes |
def test_get_input_activation2(self, rank, fn, op_name): g = tf.get_default_graph() inputs = tf.zeros([6] * rank) with arg_scope([ layers.conv2d, layers.conv2d_transpose, layers.separable_conv2d, layers.conv3d ], scope='test_layer'): _ = fn(inputs) for op in g.get_operations(): print(op.name) self.assertEqual( inputs, cc.get_input_activation( g.get_operation_by_name('test_layer/' + op_name)))
Example #15
Source File: ops.py From SSGAN-Tensorflow with MIT License | 5 votes |
def deconv2d(input, output_shape, is_train, info=False, k=3, s=2, stddev=0.01, activation_fn=tf.nn.relu, norm='batch', name='deconv2d'): with tf.variable_scope(name): _ = layers.conv2d_transpose( input, num_outputs=output_shape, weights_initializer=tf.truncated_normal_initializer(stddev=stddev), biases_initializer=tf.zeros_initializer(), activation_fn=None, kernel_size=[k, k], stride=[s, s], padding='SAME' ) _ = norm_and_act(_, is_train, norm=norm, activation_fn=activation_fn) if info: print_info(name, _.get_shape().as_list(), activation_fn) return _
Example #16
Source File: pggan_utils.py From TwinGAN with Apache License 2.0 | 4 votes |
def pggan_arg_scope(norm_type=None, conditional_layer=None, norm_var_scope_postfix='', weights_init_stddev=0.02, weight_decay=0.0, is_training=False, reuse=None): """ :param norm_type: A string specifying the normalization type. See norm type constants for allowed values. :param conditional_layer: A tensor that the norm parameters are conditioned on. :param norm_var_scope_postfix: A string. Optional postfix to the normalizer variable scopes. For example if postfix is 'pf', then norm variable 'alpha' will become 'alpha_pf'. :param weights_init_stddev: A float. Standard deviation of the weight initializer. :param weight_decay: A float. Optional decay to apply to weights. :param is_training: A boolean. Used by the normalizers such as batch norm. :param reuse: A boolean. If set, reuse variables. :return: """ normalizer_fn, norm_params = get_normalizer_fn_and_params( norm_type, conditional_layer=conditional_layer, var_scope_postfix=norm_var_scope_postfix, is_training=is_training, reuse=reuse) weights_regularizer = None if weight_decay and weight_decay > 0.0: weights_regularizer = layers.l2_regularizer(weight_decay) if FLAGS.equalized_learning_rate: # In equalized learning rate, weights are initialized using N(0,1), then explicitly scaled at runtime. weights_init_stddev = 1.0 with tf.contrib.framework.arg_scope( [layers.conv2d, layers.conv2d_transpose, ops.convolution], # Note: the activation is added after the normalizer_fn. activation_fn=DEFAULT_ACTIVATION_FN, # Note: In the PGGAN paper pixel norm is used for generator and no normalization is used for the discriminator. normalizer_fn=normalizer_fn, normalizer_params=norm_params, weights_initializer=tf.random_normal_initializer(0, weights_init_stddev), weights_regularizer=weights_regularizer, stride=1, kernel_size=DEFAULT_KERNEL_SIZE, padding='SAME', reuse=reuse) as sc: return sc
Example #17
Source File: hyperparams_builder.py From aster with MIT License | 4 votes |
def build(hyperparams_config, is_training): """Builds arg_scope for convolution ops based on the config. Returns an arg_scope to use for convolution ops containing weights initializer, weights regularizer, activation function, batch norm function and batch norm parameters based on the configuration. Note that if the batch_norm parameteres are not specified in the config (i.e. left to default) then batch norm is excluded from the arg_scope. The batch norm parameters are set for updates based on `is_training` argument and conv_hyperparams_config.batch_norm.train parameter. During training, they are updated only if batch_norm.train parameter is true. However, during eval, no updates are made to the batch norm variables. In both cases, their current values are used during forward pass. Args: hyperparams_config: hyperparams.proto object containing hyperparameters. is_training: Whether the network is in training mode. Returns: arg_scope: arg_scope containing hyperparameters for ops. Raises: ValueError: if hyperparams_config is not of type hyperparams.Hyperparams. """ if not isinstance(hyperparams_config, hyperparams_pb2.Hyperparams): raise ValueError('hyperparams_config not of type ' 'hyperparams_pb.Hyperparams.') batch_norm = None batch_norm_params = None if hyperparams_config.HasField('batch_norm'): batch_norm = layers.batch_norm batch_norm_params = _build_batch_norm_params( hyperparams_config.batch_norm, is_training) affected_ops = [layers.conv2d, layers.separable_conv2d, layers.conv2d_transpose] if hyperparams_config.HasField('op') and ( hyperparams_config.op == hyperparams_pb2.Hyperparams.FC): affected_ops = [layers.fully_connected] with arg_scope( affected_ops, weights_regularizer=_build_regularizer( hyperparams_config.regularizer), weights_initializer=_build_initializer( hyperparams_config.initializer), activation_fn=_build_activation_fn(hyperparams_config.activation), normalizer_fn=batch_norm, normalizer_params=batch_norm_params) as sc: return sc
Example #18
Source File: predictor.py From PRNet with MIT License | 4 votes |
def __call__(self, x, is_training = True): with tf.variable_scope(self.name) as scope: with arg_scope([tcl.batch_norm], is_training=is_training, scale=True): with arg_scope([tcl.conv2d, tcl.conv2d_transpose], activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, biases_initializer=None, padding='SAME', weights_regularizer=tcl.l2_regularizer(0.0002)): size = 16 # x: s x s x 3 se = tcl.conv2d(x, num_outputs=size, kernel_size=4, stride=1) # 256 x 256 x 16 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=2) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=1) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=2) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=1) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=2) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=1) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=2) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=1) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=2) # 8 x 8 x 512 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(se, size * 32, 4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=2) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=2) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=2) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=2) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=1) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size, 4, stride=2) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, size, 4, stride=1) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pos = tcl.conv2d_transpose(pd, 3, 4, stride=1, activation_fn = tf.nn.sigmoid)#, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) return pos
Example #19
Source File: predictor.py From MaskInsightface with Apache License 2.0 | 4 votes |
def __call__(self, x, is_training = True): with tf.variable_scope(self.name) as scope: with arg_scope([tcl.batch_norm], is_training=is_training, scale=True): with arg_scope([tcl.conv2d, tcl.conv2d_transpose], activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, biases_initializer=None, padding='SAME', weights_regularizer=tcl.l2_regularizer(0.0002)): size = 16 # x: s x s x 3 se = tcl.conv2d(x, num_outputs=size, kernel_size=4, stride=1) # 256 x 256 x 16 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=2) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=1) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=2) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=1) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=2) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=1) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=2) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=1) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=2) # 8 x 8 x 512 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(se, size * 32, 4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=2) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=2) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=2) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=2) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=1) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size, 4, stride=2) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, size, 4, stride=1) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pos = tcl.conv2d_transpose(pd, 3, 4, stride=1, activation_fn = tf.nn.sigmoid)#, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) return pos
Example #20
Source File: predictor.py From LipReading with MIT License | 4 votes |
def __call__(self, x, is_training = True): with tf.variable_scope(self.name) as scope: with arg_scope([tcl.batch_norm], is_training=is_training, scale=True): with arg_scope([tcl.conv2d, tcl.conv2d_transpose], activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, biases_initializer=None, padding='SAME', weights_regularizer=tcl.l2_regularizer(0.0002)): size = 16 # x: s x s x 3 se = tcl.conv2d(x, num_outputs=size, kernel_size=4, stride=1) # 256 x 256 x 16 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=2) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=1) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=2) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=1) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=2) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=1) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=2) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=1) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=2) # 8 x 8 x 512 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(se, size * 32, 4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=2) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=2) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=2) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=2) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=1) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size, 4, stride=2) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, size, 4, stride=1) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pos = tcl.conv2d_transpose(pd, 3, 4, stride=1, activation_fn = tf.nn.sigmoid)#, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) return pos
Example #21
Source File: prnet.py From LipReading with MIT License | 4 votes |
def __call__(self, x, is_training=True): with tf.variable_scope(self.name) as scope: with arg_scope([tcl.batch_norm], is_training=is_training, scale=True): with arg_scope([tcl.conv2d, tcl.conv2d_transpose], activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, biases_initializer=None, padding='SAME', weights_regularizer=tcl.l2_regularizer(0.0002)): size = 16 # x: s x s x 3 se = tcl.conv2d(x, num_outputs=size, kernel_size=4, stride=1) # 256 x 256 x 16 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=2) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=1) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=2) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=1) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=2) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=1) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=2) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=1) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=2) # 8 x 8 x 512 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(se, size * 32, 4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=2) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=2) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=2) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=2) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=1) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size, 4, stride=2) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, size, 4, stride=1) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pos = tcl.conv2d_transpose(pd, 3, 4, stride=1, activation_fn=tf.nn.sigmoid) # , padding='SAME', weights_initializer=tf.random_normal_initializer( # 0, 0.02)) return pos
Example #22
Source File: predictor.py From PRNet-Depth-Generation with MIT License | 4 votes |
def __call__(self, x, is_training = True): with tf.variable_scope(self.name) as scope: with arg_scope([tcl.batch_norm], is_training=is_training, scale=True): with arg_scope([tcl.conv2d, tcl.conv2d_transpose], activation_fn=tf.nn.relu, normalizer_fn=tcl.batch_norm, biases_initializer=None, padding='SAME', weights_regularizer=tcl.l2_regularizer(0.0002)): size = 16 # x: s x s x 3 se = tcl.conv2d(x, num_outputs=size, kernel_size=4, stride=1) # 256 x 256 x 16 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=2) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 2, kernel_size=4, stride=1) # 128 x 128 x 32 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=2) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 4, kernel_size=4, stride=1) # 64 x 64 x 64 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=2) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 8, kernel_size=4, stride=1) # 32 x 32 x 128 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=2) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 16, kernel_size=4, stride=1) # 16 x 16 x 256 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=2) # 8 x 8 x 512 se = resBlock(se, num_outputs=size * 32, kernel_size=4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(se, size * 32, 4, stride=1) # 8 x 8 x 512 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=2) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 16, 4, stride=1) # 16 x 16 x 256 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=2) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 8, 4, stride=1) # 32 x 32 x 128 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=2) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 4, 4, stride=1) # 64 x 64 x 64 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=2) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size * 2, 4, stride=1) # 128 x 128 x 32 pd = tcl.conv2d_transpose(pd, size, 4, stride=2) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, size, 4, stride=1) # 256 x 256 x 16 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pd = tcl.conv2d_transpose(pd, 3, 4, stride=1) # 256 x 256 x 3 pos = tcl.conv2d_transpose(pd, 3, 4, stride=1, activation_fn = tf.nn.sigmoid)#, padding='SAME', weights_initializer=tf.random_normal_initializer(0, 0.02)) return pos