Commit 2c9a1100 authored by Dan O'Shea's avatar Dan O'Shea
Browse files

Restoring old do_bias=False logic, keeping trainable option

parent 0c1d2961
......@@ -148,24 +148,21 @@ def init_linear(in_size, out_size, do_bias=True, mat_init_value=None,
else:
w = tf.get_variable(wname, [in_size, out_size], initializer=mat_init,
collections=w_collections, trainable=trainable)
b = None
if do_bias:
b_collections = [tf.GraphKeys.GLOBAL_VARIABLES]
if collections:
b_collections += collections
bname = (name + "/b") if name else "/b"
if do_bias:
if bias_init_value is None:
b = tf.get_variable(bname, [1, out_size],
initializer=tf.zeros_initializer(),
collections=b_collections, trainable=trainable)
collections=b_collections,
trainable=trainable)
else:
b = tf.Variable(bias_init_value, name=bname,
collections=b_collections, trainable=trainable)
else:
# construct a non-learnable vector of zeros as the bias
b = tf.get_variable(bname, [1, out_size],
initializer=tf.zeros_initializer(),
collections=b_collections, trainable=False)
collections=b_collections,
trainable=trainable)
return (w, b)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment