我正在尝试使用简单的分类器训练一个简单的单热矢量线性自动编码器。但是我的权重没有更新。你能告诉我为什么吗?
tag_seq_size=30
encode_size=10
X = tf.placeholder(tf.float32,shape=[None,tag_seq_size])
W1 = tf.Variable(np.ones((tag_seq_size,encode_size),dtype=np.float32))
W2 = tf.Variable(np.ones((encode_size,tag_seq_size),dtype=np.float32))
hidden = tf.matmul(X,W1)
Y = tf.matmul(hidden,W2)
loss = tf.reduce_mean(tf.square(Y-X))
optimizer = tf.train.AdamOptimizer(learning_rate=0.01)
train=optimizer.minimize(loss)
num_steps = 1000
init=tf.global_variables_initializer()
with tf.Session() as sess:
for i in range(num_steps):
sess.run(init)
sess.run(train,feed_dict={X:Data})