python类truncated_normal()的实例源码

demo.py 文件源码 项目:how_to_convert_text_to_images 作者: llSourcell 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def sample_encoded_context(embeddings, model, bAugmentation=True):
    '''Helper function for init_opt'''
    # Build conditioning augmentation structure for text embedding
    # under different variable_scope: 'g_net' and 'hr_g_net'
    c_mean_logsigma = model.generate_condition(embeddings)
    mean = c_mean_logsigma[0]
    if bAugmentation:
        # epsilon = tf.random_normal(tf.shape(mean))
        epsilon = tf.truncated_normal(tf.shape(mean))
        stddev = tf.exp(c_mean_logsigma[1])
        c = mean + stddev * epsilon
    else:
        c = mean
    return c
cnn_solution.py 文件源码 项目:Kaggle 作者: lawlite19 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def weight_variable(shape):
    inital = tf.truncated_normal(shape, stddev=0.1)
    return tf.Variable(inital)
network.py 文件源码 项目:EWC 作者: stokesj 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def create_variable(shape, name, c=None, sigma=None, trainable=True):
        if sigma:
            initial = tf.truncated_normal(shape, stddev=sigma, name=name)
        else:
            initial = tf.constant(c if c else 0.0, shape=shape, name=name)
        return tf.Variable(initial, trainable=trainable)
Layers.py 文件源码 项目:ISLES2017 作者: MiguelMonteiro 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def xavier_normal_dist(shape):
    return tf.truncated_normal(shape, mean=0, stddev=tf.sqrt(3. / shape[-1] + shape[-2]))
Layers.py 文件源码 项目:ISLES2017 作者: MiguelMonteiro 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def xavier_normal_dist_conv3d(shape):
    return tf.truncated_normal(shape, mean=0,
                               stddev=tf.sqrt(3. / (tf.reduce_prod(shape[:3]) * tf.reduce_sum(shape[3:]))))
Layers.py 文件源码 项目:ISLES2017 作者: MiguelMonteiro 项目源码 文件源码 阅读 67 收藏 0 点赞 0 评论 0
def convolution_layer_3d(layer_input, filter, strides, padding='SAME'):
    assert len(filter) == 5  # [filter_depth, filter_height, filter_width, in_channels, out_channels]
    assert len(strides) == 5  # must match input dimensions [batch, in_depth, in_height, in_width, in_channels]
    assert padding in ['VALID', 'SAME']
    # w = tf.Variable(initial_value=tf.truncated_normal(shape=filter), name='weights')

    w = tf.Variable(initial_value=xavier_uniform_dist_conv3d(shape=filter), name='weights')

    b = tf.Variable(tf.constant(1.0, shape=[filter[-1]]), name='biases')
    convolution = tf.nn.conv3d(layer_input, w, strides, padding)
    return convolution + b
Layers.py 文件源码 项目:ISLES2017 作者: MiguelMonteiro 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def deconvolution_layer_3d(layer_input, filter, output_shape, strides, padding='SAME'):
    assert len(filter) == 5  # [depth, height, width, output_channels, in_channels]
    assert len(strides) == 5  # must match input dimensions [batch, depth, height, width, in_channels]
    assert padding in ['VALID', 'SAME']
    # w = tf.Variable(initial_value=tf.truncated_normal(shape=filter), name='weights')
    w = tf.Variable(initial_value=xavier_uniform_dist_conv3d(shape=filter), name='weights')
    b = tf.Variable(tf.constant(1.0, shape=[filter[-2]]), name='biases')
    deconvolution = tf.nn.conv3d_transpose(layer_input, w, output_shape, strides, padding)
    return deconvolution + b
model.py 文件源码 项目:tf-crnn 作者: solivr 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def weightVar(shape, mean=0.0, stddev=0.02, name='weights'):
    init_w = tf.truncated_normal(shape=shape, mean=mean, stddev=stddev)
    return tf.Variable(init_w, name=name)
AveragePolicyNetwork.py 文件源码 项目:RL_NFSP 作者: Richard-An 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def weight_variable(self, shape, name):
        initial = tf.truncated_normal(shape, stddev=0.01)
        return tf.get_variable(name=name, initializer=initial, trainable=True)
AveragePolicyNetwork.py 文件源码 项目:RL_NFSP 作者: Richard-An 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def weight_variable(self, shape):
        initial = tf.truncated_normal(shape, stddev=0.01)
        return tf.Variable(initial)
DQN_DouDiZhu.py 文件源码 项目:RL_NFSP 作者: Richard-An 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def weight_variable(self, shape):
        initial = tf.truncated_normal(shape, stddev=0.01)
        return tf.Variable(initial)
AveragePolicyNetwork.py 文件源码 项目:RL_NFSP 作者: Richard-An 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def weight_variable(self, shape, name):
        initial = tf.truncated_normal(shape, stddev=0.01)
        return tf.get_variable(name=name, initializer=initial, trainable=True)
DQN_DouDiZhu.py 文件源码 项目:RL_NFSP 作者: Richard-An 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def weight_variable(self, shape, name):
        initial = tf.truncated_normal(shape, stddev=0.01)
        return tf.get_variable(name=name, initializer=initial, trainable=True)
cnn.py 文件源码 项目:DeepLearning 作者: STHSF 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def weight_variable(shape):
    initial = tf.truncated_normal(shape, stddev=0.1)
    return tf.Variable(initial)
run.py 文件源码 项目:handwritten-sequence-tensorflow 作者: johnsmithm 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def weight_variable(self,shape,name="v"):
        if self.initializer == "graves" and False:
            initial = tf.truncated_normal_initializer(mean=0., stddev=.075, seed=None, dtype=tf.float32)
        else:
            initial = tf.truncated_normal(shape, stddev=.075)
        return tf.Variable(initial,name=name+"_weight")
q_network.py 文件源码 项目:agent-trainer 作者: lopespm 项目源码 文件源码 阅读 51 收藏 0 点赞 0 评论 0
def _linear_layer(self, input, input_size, output_size, scope_name):
        with tf.variable_scope(scope_name) as scope:
            weights = tf.Variable(name='weights',
                                  initial_value=tf.truncated_normal(shape=[input_size, output_size], stddev=0.1))
            biases = tf.Variable(name='biases', initial_value=tf.constant(value=0.1, shape=[output_size]))
            output = tf.matmul(input, weights) + biases
        return output
madry_mnist_model.py 文件源码 项目:cleverhans 作者: tensorflow 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def _weight_variable(shape):
        initial = tf.truncated_normal(shape, stddev=0.1)
        return tf.Variable(initial)
model.py 文件源码 项目:fold 作者: tensorflow 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, embedding_length):
    self._embedding_length = embedding_length
    self._named_tensors = {}

    for n in xrange(10):
      # Note: the examples only have the numbers 0 through 9 as terminal nodes.
      name = 'terminal_' + str(n)
      self._named_tensors[name] = tf.Variable(
          tf.truncated_normal([embedding_length],
                              dtype=tf.float32,
                              stddev=1),
          name=name)

    self._combiner_weights = {}
    self._loom_ops = {}
    for name in calculator_pb2.CalculatorExpression.OpCode.keys():
      weights_var = tf.Variable(
          tf.truncated_normal([2 * embedding_length, embedding_length],
                              dtype=tf.float32,
                              stddev=1),
          name=name)
      self._combiner_weights[name] = weights_var
      self._loom_ops[name] = CombineLoomOp(2, embedding_length, weights_var)

    self._loom = loom.Loom(
        named_tensors=self._named_tensors,
        named_ops=self._loom_ops)

    self._output = self._loom.output_tensor(
        loom.TypeShape('float32', [embedding_length]))
tfbasemodel.py 文件源码 项目:Supply-demand-forecasting 作者: LevinJ 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def weight_variable(self, shape):
        """Create a weight variable with appropriate initialization."""
        initial = tf.truncated_normal(shape, stddev=0.1)
        return tf.Variable(initial)


问题


面经


文章

微信
公众号

扫码关注公众号