Python 在没有keras的情况下,如何计算tensorflow上的列车和验证损失?
作为第一步,我想在每个历元后使用tensorflow复制keras损失和验证损失打印值。我当前的代码如下所示:Python 在没有keras的情况下,如何计算tensorflow上的列车和验证损失?,python,tensorflow,Python,Tensorflow,作为第一步,我想在每个历元后使用tensorflow复制keras损失和验证损失打印值。我当前的代码如下所示: optimizer = tf.train.AdamOptimizer(0.01) X = tf.placeholder("float", [None, num_features]) y_pred = autoencoder_model #This is my model with layers, weights and biases y_true = X l
optimizer = tf.train.AdamOptimizer(0.01)
X = tf.placeholder("float", [None, num_features])
y_pred = autoencoder_model #This is my model with layers, weights and biases
y_true = X
loss = tf.reduce_mean(tf.pow(y_true - y_pred,2))
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
for epoch in range(training_epochs):
for batch in range(bathces):
batch_x = data[batch]
_, c = sess.run([optimizer, loss], feed_dict = {X: batch_x})
print('loss is {}'.format(c))
#### print('val loss is {}'.format()) Need to print validation loss here