Giter Club home page Giter Club logo

Comments (4)

fchollet avatar fchollet commented on July 18, 2024

The first step (or two steps sometimes) cover compilation time too (which is why they tend to take much longer). The other steps cover a full forward pass, which includes updating the variables.

from keras.

wortelus avatar wortelus commented on July 18, 2024

Hey there, thanks for the quick response!

By first step you mean calling the model.predict for the first time (or second, as you said) in the given session? Hence making the subsequent calls being only the forward pass through the network? In both cases, the time reported in the stdout are covering only said phases? Is the data transfer between memory and GPU also included?

Sorry if I am misunderstanding this.

Warm regards,
wortelus

from keras.

fchollet avatar fchollet commented on July 18, 2024

By first step you mean calling the model.predict for the first time (or second, as you said) in the given session?

predict() (and fit, evaluate) are loops. The inner content of that loop is called a "step". One call to predict() might have, say, 1000 steps. Compilation only happens at the first step, the first time predict() is called. Subsequent steps and subsequent calls to predict() reuse the same compiled graph.

Hence making the subsequent calls being only the forward pass through the network? In both cases, the time reported in the stdout are covering only said phases? Is the data transfer between memory and GPU also included?

Yes.

from keras.

wortelus avatar wortelus commented on July 18, 2024

I now understand that the time I get to stdout is part of Keras callback using, specifically Progbar class, with its methods that are executed before and after the main loop, as seen here from trainer.py

self.make_predict_function()
self.stop_predicting = False
callbacks.on_predict_begin()
outputs = None
with epoch_iterator.catch_stop_iteration():
    for step, iterator in epoch_iterator.enumerate_epoch():
        callbacks.on_predict_batch_begin(step)
        data = get_data(iterator)
        batch_outputs = self.predict_function(data)
        outputs = append_to_outputs(batch_outputs, outputs)
        callbacks.on_predict_batch_end(step, {"outputs": batch_outputs})
        if self.stop_predicting:
            break
callbacks.on_predict_end()
outputs = tree.map_structure_up_to(
    batch_outputs, potentially_ragged_concat, outputs
)
return tree.map_structure(convert_to_np_if_not_ragged, outputs)

I suppose the compilation happens under self.make_predict_function().

I now understand the source of the time, as the time is managed under callbacks.on_predict_begin() and callbacks.on_predict_end(), respectively. My question is then at what point in the predict() is the data loaded into the GPU, so I can know if the time within the progress bar includes the IO GPU<->memory operations or if (some) data are already present on the GPU beforehand.

Kind regards,
wortelus

from keras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.