in utils.py [0:0]
def init_attention_weight(
weights,
scope,
c_in,
k,
trainable_gamma=True,
spec_norm=True):
if spec_norm:
spec_norm = FLAGS.spec_norm
atten_weights = {}
with tf.variable_scope(scope):
atten_weights['q'] = get_weight(
'atten_q', [1, 1, c_in, k], spec_norm=spec_norm)
atten_weights['q_b'] = tf.get_variable(
shape=[k], name='atten_q_b1', initializer=tf.initializers.zeros())
atten_weights['k'] = get_weight(
'atten_k', [1, 1, c_in, k], spec_norm=spec_norm)
atten_weights['k_b'] = tf.get_variable(
shape=[k], name='atten_k_b1', initializer=tf.initializers.zeros())
atten_weights['v'] = get_weight(
'atten_v', [1, 1, c_in, c_in], spec_norm=spec_norm)
atten_weights['v_b'] = tf.get_variable(
shape=[c_in], name='atten_v_b1', initializer=tf.initializers.zeros())
atten_weights['gamma'] = tf.get_variable(
shape=[1], name='gamma', initializer=tf.initializers.zeros())
weights[scope] = atten_weights