Why model.fit_generator in keras is taking so much time even before picking the data? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsKeras val_acc unchanging when training (same label assigned to all images)Keras - Why Validation data produce good results, while unseen data is performing poorlyReformatting data for future time series prediction LSTM(Keras)How to change the pooling to adaptpooling before FC layer in the Inception-ResnetV2 model in kerasWhy running the same code on the same data gives a different result every time?Understanding Timestamps and Batchsize of Keras LSTM considering Hiddenstates and TBPTTWhy does my Keras model learn to recognize the background?Why is my Keras model not learning image segmentation?LSTM Multi-state forecastFiltering data before passing through LSTM then returning the filtered data back into the results
Single word antonym of "flightless"
How to find all the available tools in mac terminal?
How to tell that you are a giant?
Why didn't this character "real die" when they blew their stack out in Altered Carbon?
Can I cast Passwall to drop an enemy into a 20-foot pit?
What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?
3 doors, three guards, one stone
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
What does "fit" mean in this sentence?
List of Python versions
How does the particle を relate to the verb 行く in the structure「A を + B に行く」?
Is it true that "carbohydrates are of no use for the basal metabolic need"?
Can a non-EU citizen traveling with me come with me through the EU passport line?
Short Story with Cinderella as a Voo-doo Witch
How to answer "Have you ever been terminated?"
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
What does the "x" in "x86" represent?
Do I really need recursive chmod to restrict access to a folder?
What is Arya's weapon design?
Why aren't air breathing engines used as small first stages
Why do people hide their license plates in the EU?
Coloring maths inside a tcolorbox
What's the purpose of writing one's academic biography in the third person?
What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?
Why model.fit_generator in keras is taking so much time even before picking the data?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsKeras val_acc unchanging when training (same label assigned to all images)Keras - Why Validation data produce good results, while unseen data is performing poorlyReformatting data for future time series prediction LSTM(Keras)How to change the pooling to adaptpooling before FC layer in the Inception-ResnetV2 model in kerasWhy running the same code on the same data gives a different result every time?Understanding Timestamps and Batchsize of Keras LSTM considering Hiddenstates and TBPTTWhy does my Keras model learn to recognize the background?Why is my Keras model not learning image segmentation?LSTM Multi-state forecastFiltering data before passing through LSTM then returning the filtered data back into the results
$begingroup$
In Keras, I am training a model as in below
model.fit_generator(data_generator(),
samples_per_epoch = count,
validation_data=(x_val, y_val),
nb_epoch=50,
callbacks=getCallBacks(),
verbose=1)
In data_generator function, I am printing few debugging statements.
On running above fit_generator function, it takes really long time to print what I had put in the data_generator().
Is there any series of steps which keras takes before picking out the data batch for the training which makes the process so slow or there is some other caveat?
keras
$endgroup$
bumped to the homepage by Community♦ 22 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
$begingroup$
In Keras, I am training a model as in below
model.fit_generator(data_generator(),
samples_per_epoch = count,
validation_data=(x_val, y_val),
nb_epoch=50,
callbacks=getCallBacks(),
verbose=1)
In data_generator function, I am printing few debugging statements.
On running above fit_generator function, it takes really long time to print what I had put in the data_generator().
Is there any series of steps which keras takes before picking out the data batch for the training which makes the process so slow or there is some other caveat?
keras
$endgroup$
bumped to the homepage by Community♦ 22 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48
add a comment |
$begingroup$
In Keras, I am training a model as in below
model.fit_generator(data_generator(),
samples_per_epoch = count,
validation_data=(x_val, y_val),
nb_epoch=50,
callbacks=getCallBacks(),
verbose=1)
In data_generator function, I am printing few debugging statements.
On running above fit_generator function, it takes really long time to print what I had put in the data_generator().
Is there any series of steps which keras takes before picking out the data batch for the training which makes the process so slow or there is some other caveat?
keras
$endgroup$
In Keras, I am training a model as in below
model.fit_generator(data_generator(),
samples_per_epoch = count,
validation_data=(x_val, y_val),
nb_epoch=50,
callbacks=getCallBacks(),
verbose=1)
In data_generator function, I am printing few debugging statements.
On running above fit_generator function, it takes really long time to print what I had put in the data_generator().
Is there any series of steps which keras takes before picking out the data batch for the training which makes the process so slow or there is some other caveat?
keras
keras
asked Jun 19 '18 at 9:23
Divyanshu ShekharDivyanshu Shekhar
184113
184113
bumped to the homepage by Community♦ 22 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 22 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48
add a comment |
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
I have noticed this when training on one or more GPUs. I think it is due to Tensorflow having to acquire the resources (in the background it blocks the entire GPU memory). Perhaps some amount of data e.g. the first batch is copied over to the GPU.
I didn't find a way to reduce the waiting time dramatically, but you could try the tensorflow options to allocate less memory and allow memory growth as required. Check out the official docs and this issue for the Keras version.
Here is the latest recommendation form that issue: setting Tensorflow options befor eimporting Keras.
-------------------------- set gpu using tf ---------------------------
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
------------------- start importing keras module ---------------------
import keras.backend.tensorflow_backend as K
import keras......
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "557"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f33364%2fwhy-model-fit-generator-in-keras-is-taking-so-much-time-even-before-picking-the%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I have noticed this when training on one or more GPUs. I think it is due to Tensorflow having to acquire the resources (in the background it blocks the entire GPU memory). Perhaps some amount of data e.g. the first batch is copied over to the GPU.
I didn't find a way to reduce the waiting time dramatically, but you could try the tensorflow options to allocate less memory and allow memory growth as required. Check out the official docs and this issue for the Keras version.
Here is the latest recommendation form that issue: setting Tensorflow options befor eimporting Keras.
-------------------------- set gpu using tf ---------------------------
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
------------------- start importing keras module ---------------------
import keras.backend.tensorflow_backend as K
import keras......
$endgroup$
add a comment |
$begingroup$
I have noticed this when training on one or more GPUs. I think it is due to Tensorflow having to acquire the resources (in the background it blocks the entire GPU memory). Perhaps some amount of data e.g. the first batch is copied over to the GPU.
I didn't find a way to reduce the waiting time dramatically, but you could try the tensorflow options to allocate less memory and allow memory growth as required. Check out the official docs and this issue for the Keras version.
Here is the latest recommendation form that issue: setting Tensorflow options befor eimporting Keras.
-------------------------- set gpu using tf ---------------------------
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
------------------- start importing keras module ---------------------
import keras.backend.tensorflow_backend as K
import keras......
$endgroup$
add a comment |
$begingroup$
I have noticed this when training on one or more GPUs. I think it is due to Tensorflow having to acquire the resources (in the background it blocks the entire GPU memory). Perhaps some amount of data e.g. the first batch is copied over to the GPU.
I didn't find a way to reduce the waiting time dramatically, but you could try the tensorflow options to allocate less memory and allow memory growth as required. Check out the official docs and this issue for the Keras version.
Here is the latest recommendation form that issue: setting Tensorflow options befor eimporting Keras.
-------------------------- set gpu using tf ---------------------------
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
------------------- start importing keras module ---------------------
import keras.backend.tensorflow_backend as K
import keras......
$endgroup$
I have noticed this when training on one or more GPUs. I think it is due to Tensorflow having to acquire the resources (in the background it blocks the entire GPU memory). Perhaps some amount of data e.g. the first batch is copied over to the GPU.
I didn't find a way to reduce the waiting time dramatically, but you could try the tensorflow options to allocate less memory and allow memory growth as required. Check out the official docs and this issue for the Keras version.
Here is the latest recommendation form that issue: setting Tensorflow options befor eimporting Keras.
-------------------------- set gpu using tf ---------------------------
import tensorflow as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
------------------- start importing keras module ---------------------
import keras.backend.tensorflow_backend as K
import keras......
answered Jun 19 '18 at 10:16
n1k31t4n1k31t4
6,5512421
6,5512421
add a comment |
add a comment |
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f33364%2fwhy-model-fit-generator-in-keras-is-taking-so-much-time-even-before-picking-the%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Did you put a debug statement at the top of your fit_generator function?
$endgroup$
– Imran
Dec 17 '18 at 21:48