Zero initializer for offsets using get_variable in a tensor stream

The code I'm modifying uses tf.get_variablefor weight variables and tf.Variableto initialize the offset. After some searching, it seems that get_variableit should always be approved due to its portability regarding sharing. So I tried changing the offset variable to get_variable, but it can't seem to make it work.

Original: tf.Variable(tf.zeros([128]), trainable=True, name="b1")

My attempt: tf.get_variable(name="b1", shape=[128], initializer=tf.zeros_initializer(shape=[128]))

I get a message that the form should not be specified for constants. But deleting the form then causes an error with no arguments.

I am very new to tf, so I probably misunderstand something fundamental. Thanks for the help in advance.

+4
source share
1 answer

The following should work: tf.get_variable(name="b1", shape=[128], initializer=tf.zeros_initializer())

+8
source

Source: https://habr.com/ru/post/1667608/


All Articles