Skip to content

Commit

Permalink
noisy net
Browse files Browse the repository at this point in the history
  • Loading branch information
shixiaowen03 committed Dec 18, 2018
1 parent 48c04b3 commit 62bca23
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/tensorflow1.2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 55 additions & 68 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions RL/Basic-NoisyNet-Demo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def f(e_list):
inputs = tf.contrib.layers.flatten(inputs)
flatten_shape = inputs.shape[1]
weights = tf.get_variable('weights', shape=[flatten_shape, units], initializer=w_i)
w_noise = tf.get_variable('w_noise', [flatten_shape, units], initializer=w_i, collections=c_names)
w_sigma = tf.get_variable('w_sigma', [flatten_shape, units], initializer=w_i, collections=c_names)
if noisy_distribution == 'independent':
weights += tf.multiply(tf.random_normal(shape=w_noise.shape), w_noise)
weights += tf.multiply(tf.random_normal(shape=w_sigma.shape), w_sigma)
elif noisy_distribution == 'factorised':
noise_1 = f(tf.random_normal(tf.TensorShape([flatten_shape, 1]), dtype=tf.float32)) # 注意是列向量形式,方便矩阵乘法
noise_2 = f(tf.random_normal(tf.TensorShape([1, units]), dtype=tf.float32))
weights += tf.multiply(noise_1 * noise_2, w_noise)
weights += tf.multiply(noise_1 * noise_2, w_sigma)
dense = tf.matmul(inputs, weights)
if bias_shape is not None:
assert bias_shape[0] == units
Expand Down
Loading

0 comments on commit 62bca23

Please sign in to comment.