astorfi / TensorFlow-World

:earth_americas: Simple and ready-to-use tutorials for TensorFlow
MIT License
4.53k stars 417 forks source link

train_op in linear regression #12

Closed mzur closed 7 years ago

mzur commented 7 years ago

Is defining train_op for each data point and epoch anew really needed? I'm new to TensorFlow so I can't tell why or why not this would make sense. For me, the regression seems to work fine (and much faster) if the line is removed.

astorfi commented 7 years ago

Thank you so much for spending time and reading it. Basically, train_op is a crucial graph tensor which must be run by the TensorFlow session to perform a training step. As an example, performing a training step can be equivalent to updating the weights. In the code that you mentioned. train_op is the optimizer object, not just the loss.

You can refer to TensorFlow Mechanics for further details. Moreover, a detailed explanation is provided in Convolutional Neural Networks documentation.

mzur commented 7 years ago

Thanks for the explanation.