0
$\begingroup$

I have read a lot of information about several notions, like batch_size, epochs, iterations, but because of explanation was without numerical examples and I am not native speaker, I have some kind of problem of understanding still about those terms, so I decided to work with data. Let us suppose we have the following data

enter image description here

Of course, it is just subset of original data, and I want to build a neural network with three hidden layers, the first layer contains 500 nodes, it takes input three variable and on each node, there is sigmoid activation function, next layer contains 100 node and sigmoid activation, the third one contains 50 node and sigmoid again, and finally we have one output with sigmoid to convert the result into 0 or 1 that classify whether a person with those attributes is female or male.

I trained the model using Keras Tensorflow with the following code

model.fit(X_train,y_train,epochs=30)

With this data, what does mean epochs=30? Does it mean that all 177 rows (with 3 input at times) will go to the model 30 times? What about batch_size=None in model.fit parameters?

$\endgroup$
  • 1
    $\begingroup$ Hi dato, I think your question have a lot of irrelevant information, what is your main question? $\endgroup$ – malioboro Apr 1 at 23:27
  • $\begingroup$ i wanted to understand following thing : if my train data has size of (177,3) and batch size is 2 , let say, how update process is going? let us suppose neural network takes 3 input and 1 output $\endgroup$ – dato datuashvili Apr 1 at 23:28
  • $\begingroup$ @malioboro i have answered and could you please check if it is correct? $\endgroup$ – dato datuashvili Apr 1 at 23:56
  • 1
    $\begingroup$ Hi and welcome to AI SE! If you're asking how a certain library, method or API works, then your question is off-topic here. See ai.stackexchange.com/help/on-topic for more details. You should ask these questions on Stack Overflow. $\endgroup$ – nbro Apr 2 at 0:53
1
$\begingroup$

Batch size and epochs are independent parameters - they serve very different purposes. Your main question as I understand it (and for general, non-library specific consumption) is what is an epoch and how is the data used for each epoch?

Simply put, an epoch is a single iteration though the training data. Each and every sample from your training dataset will be used once per epoch, whether it is for training or validation. Therefore, the more epochs, the more the model is trained. The key is to identify the number of epochs that fits the model to the data without overfitting.

Your explaination of how batch size affects the training process is correct but not relevant to the question since it has no relation to the epoch training iterations. That is not to say that these values should be considered independently since they have similar effects on the model training process.

| improve this answer | |
$\endgroup$
0
$\begingroup$

ok so let me explain in my word how i understood this process: i know that one sample mean one row, therefore if we have data with size(177,3), that means we have 177 sample. because we have divided X and y into training and test, therefore we have following pairs (X_train,y_train) and (X_test, y_test)

now about batch size, if we have let say 177 sample(177 row) and 2 batch_size , that means we have approximately $177/2$ batch right?update process goes like this:

let us suppose network takes 3 input and produce one output, from first sample of data, three data will go to the network and output will be generated, this output will be compared to the first value of y_train and cost function will be created, then next sample will go(it means next three value) and compared to the second value of y_train, also second cost function will be generated, final cost function for first batch will be sum of those cost functions and using gradient method weights are updated, after that one new batches will go through the network and on the based on updated weights, new weights are generated, when all $177/2$ batch will be finished , it will be our 1 epoch right? is that correct?

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.