# Difference between epoch and batch size in neural network [duplicate]

I am beginner in machine learning and I came across these terms while going through code of cnn, I want to know how to what exactly they mean and other question is that when the weights of network change? after each batch size or after every epoch? Thank you.

In the context of Convolution Neural Networks (CNN), Batch size is the number of examples that are fed to the algorithm at a time. This is normally some small power of 2 like 32,64,128 etc. During training an optimization algorithm computes the average cost over a batch then runs backpropagation to update the weights. In a single epoch the algorithm is run with $n_{batches} = {n_{examples} \over batchsize}$ times. Generally the algorithm needs to train for several epochs to achieve convergence of weight values. Every batch is normally sampled randomly from the whole example set.
• Yes, all weights are updated $n_{batches}$ times in a singe epoch. – farhanhubble Mar 26 '17 at 14:56