Skip to content

"avg_cost" why accumulated by batch_loss/total_batch, instead of batch_loss/batch_size ? #81

@Harryhaha

Description

@Harryhaha

in the file https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/logistic_regression.py
When compute the value of cost and avg_cost :

with tf.Session() as sess:
sess.run(init)
# Training cycle
for epoch in range(training_epochs):
avg_cost = 0.
total_batch = int(mnist.train.num_examples/batch_size)
# Loop over all batches
for i in range(total_batch):
batch_xs, batch_ys = mnist.train.next_batch(batch_size)
# Fit training using batch data
_, c = sess.run([optimizer, cost], feed_dict={x: batch_xs,
y: batch_ys})
# Compute average loss
avg_cost += c / total_batch

When accumulate "avg_cost", why added by c/total_batch, instead of c/batch_size ?
Since "avg_cost" is the average cost for each instance.

Thanks !!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions