Tied weights in Tensorflow
来源:互联网 发布:node.js cms 开源 编辑:程序博客网 时间:2024/05/29 14:31
I have been thinking for several days about this problems.
As before, if I initialized one weight for the encoder part, and then transpose it for the decoder part. whethere it would be the tied weights?
Today, I did a experiments, and saw that it was true. See the code below:
x = tf.placeholder(dtype=tf.float32, shape=[None, 4])w = tf.Variable(tf.truncated_normal(shape=[4, 2], mean=0.0, stddev=0.1, dtype=tf.float32))b = tf.Variable(tf.constant(0.0, shape=[2], dtype=tf.float32))z = tf.nn.relu(tf.matmul(x, w) + b)w_inv = tf.transpose(w)b_inv = tf.Variable(tf.constant(0.0, shape=[4], dtype=tf.float32))rec = tf.nn.relu(tf.matmul(z, w_inv) + b_inv)loss = tf.squared_difference(x, rec)train_op = tf.train.AdamOptimizer().minimize(loss)with tf.Session() as sess: sess.run(tf.global_variables_initializer()) all_variables = tf.trainable_variables() for v in all_variables: print(v)
And the outputs:
<tf.Variable 'Variable:0' shape=(4, 2) dtype=float32_ref><tf.Variable 'Variable_1:0' shape=(2,) dtype=float32_ref><tf.Variable 'Variable_2:0' shape=(4,) dtype=float32_ref>
It is clearly, here the tied weights are successful.
阅读全文
0 0
- Tied weights in Tensorflow
- Tensorflow cifar10_multi_gpu问题:Variable conv1/weights/ExponentialMovingAverage/ does not exist
- TensorFlow学习笔记(四)自己动手求Weights和biases
- An Introduction to Interactive Programming in Python (Part 2) week 6 (Classes and Tied images)
- [TensorFlow] demo1 导入tensorflow相关的包,并生成Weights和biases
- Update TensorFlow in Mac
- Seq2Seq in Tensorflow
- Seq2Seq in Tensorflow
- Mask RCNN in TensorFlow
- TensorFlow in Go
- LSTM in tensorflow
- 跑通 MobileNet in Tensorflow
- Custom Gradients in TensorFlow
- Type erroe in tensorflow
- "nan" error in tensorflow
- Weights Update
- Error in nnet.default(x, y, w, ...) : too many (2651) weights
- Models in TensorFlow from GitHub
- IO,BIO,NIO,AIO
- 重新安装mysql 开启不了服务
- 第10个项目,构建仿真引擎
- Angular 4入门教程系列:1:运行在Docker中的HelloWorld
- 【暴力】枚举子集
- Tied weights in Tensorflow
- uninstall software on ubuntu
- 【数论】最小公倍数
- 【数论】筛素数
- mysql数据库安装与配置
- MallocCreator
- MXNet线性回归
- 欠阻尼震荡
- 云服务器上创建的网站通过ip无法访问以及访问时显示网站连接错误