def get_fc_layer(name,size):
'''
name - Name to be added after W_ and b_ (can be any datatype convertible to str)
size - [inp_size,out_size]
tf.get_variable looks for variable name in current scope and returns it.
If not found, it uses the initializer
'''
with tf.device('/cpu:0'):
W = tf.get_variable('W_'+str(name),
shape=[size[0],size[1]],
initializer=tf.contrib.layers.xavier_initializer(uniform=True,
seed=None,
dtype=tf.float32))
b = tf.get_variable('b_'+str(name),
shape=[size[1]],
initializer=tf.random_uniform_initializer(-model_options['init_scale'],\
model_options['init_scale']))
return W,b
评论列表
文章目录