Comments (4)
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.
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.
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.
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)
- Conv3D generates output on Tensorflow backend while crashes on pytorch backend HOT 4
- RNN layer: len is not well defined for a symbolic Tensor. Please call `x.shape` rather than `len(x)` for shape information. HOT 4
- keras.ops.select doesn't accept tuples as input HOT 1
- Recommendation for writing tests for ModelParallel distribution HOT 3
- optimizers.Adam no longer accepts tf.Variable HOT 1
- Please explain label_mode='int' in keras.utils.image_dataset_from_directory HOT 5
- Getting Nan values in prediction HOT 4
- compatibility with pytorch 2.3 HOT 1
- Specifying shape of normal sampling with partially empty keras tensor HOT 3
- Question: Best practice for direct variable initialization HOT 6
- Inconsistent assertion in keras.layers.MultiHeadAttention HOT 3
- [BUG] keras.layers.StringLookup and Vocabulary of Tensors HOT 3
- model.export() fails to save output layer name in the SavedModel HOT 9
- ops.linspace broken in Tensorflow when num is a tf.Tensor HOT 4
- Loading model fails: can only concatenate tuple HOT 1
- Keras `__init__.py` structure isn't readable by a static type checker HOT 12
- [BUG] Conflicting loss_weights implementation in Keras3 for single output case. HOT 3
- Most of the outbound links are broken in Tensorflow documentation HOT 3
- [Question] When is it absolutely necessary to use a `Lambda` layer? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras.