Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在没有keras的情况下,如何计算tensorflow上的列车和验证损失?_Python_Tensorflow - Fatal编程技术网

Python 在没有keras的情况下,如何计算tensorflow上的列车和验证损失?

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

作为第一步,我想在每个历元后使用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

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