Answers.Body: <p>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 <strong>what is an epoch and how is the data used for each epoch?</strong></p>
  
  <p>Simply put, an epoch is a single iteration though the training data. Each and every sample from your training dataset will be used <strong>once</strong> 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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-02T14:19:12.057Z
Answers.LastActivityDate: 2020-04-02T14:19:12.057Z
Answers.UserDisplayName: tynowell
Answers.Body: <p>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) </p>
  
  <p>now about batch size, if we have  let say 177 sample(177 row) and  2 batch_size , that means we have approximately  <span class="math-container">$177/2$</span> batch right?update process goes  like this: </p>
  
  <p>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  <span class="math-container">$177/2$</span>  batch will be finished , it will be our 1 epoch right? is that correct? </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-01T23:55:59.253Z
Answers.LastActivityDate: 2020-04-01T23:55:59.253Z
Answers.UserDisplayName: dato datuashvili
Body: <p>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</p>
  
  <p><a href="https://i.sstatic.net/BmtIx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BmtIx.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>I trained the model using Keras Tensorflow with the following code</p>
  
  <pre><code>model.fit(X_train,y_train,epochs=30)
  </code></pre>
  
  <p>With this data, what does mean <code>epochs=30</code>? Does it mean that all 177 rows  (with 3 input at times) will go to the model 30 times? What about <code>batch_size=None</code> in <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model?version=stable#fit" rel="nofollow noreferrer">model.fit parameters</a>? </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-01T23:27:34.590Z
Comments.Text: Hi dato, I think your question have a lot of irrelevant information, what is your main question?
Comments.UserDisplayName: malioboro
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-01T23:28:58.003Z
Comments.Text: 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
Comments.UserDisplayName: dato datuashvili
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-01T23:56:33.547Z
Comments.Text: @malioboro i have answered and could you please check if it is correct?
Comments.UserDisplayName: dato datuashvili
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-02T00:53:11.183Z
Comments.Text: 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 https://ai.stackexchange.com/help/on-topic for more details. You should ask these questions on Stack Overflow.
Comments.UserDisplayName: nbro
Tags: <neural-networks><deep-learning><training><keras><datasets>
Title: What does it mean to have epochs=30 in Keras' fit method given certain data?
UserDisplayName: dato datuashvili
ThreadText: # What does it mean to have epochs=30 in Keras' fit method given certain data?
  
  (Asked by: username_0 on 2020-04-01)
  
  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](https://i.sstatic.net/BmtIx.png)](https://i.sstatic.net/BmtIx.png)
  
  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](https://www.tensorflow.org/api_docs/python/tf/keras/Model?version=stable#fit)?
  
  **Tags:** neural-networks, deep-learning, training, keras, datasets
  
  > **Comments:**
  > **username_1**: Hi username_0, I think your question have a lot of irrelevant information, what is your main question?  
  > **username_0**: 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  
  > **username_0**: @username_1 i have answered and could you please check if it is correct?  
  > **username_2**: 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 https://ai.stackexchange.com/help/on-topic for more details. You should ask these questions on Stack Overflow.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2020-04-02. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  ### Answer by username_0 on 2020-04-01. Score: 0
  
  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?
  
  
  ---
  
  