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)
- Inconsistent execution results by the PyTorch backend HOT 1
- "replication_pad1d" not implemented for 'Half' HOT 2
- Add 'pip install -r requirements.txt' to devcontainer.json to reduce contribution efforts HOT 2
- Loss and Gradients not correct when last batch has different size HOT 1
- support for dictionary-type loss functions without explicitly declaring `None` HOT 1
- Model.metrics_names not returning all metrics HOT 2
- Question about Memory Leak (all backends) HOT 7
- TextVectorization returns 'int64' vs 'float32' in TF 2.7 / nightly + Training simple unigram/bigram models much slower than in 2.15 HOT 2
- Custom `tf.keras.metrics.Metric` example fails on GPU in TF 2.17 (but not on nightly): is it possible to get it to work on 2.17? HOT 3
- Allow to pass **kwargs to optimizers.get HOT 1
- How to Convert Keras Modelโs Inference Method (with JAX Backend) to Flax Training State for Using Flax to Predict HOT 5
- Early-stopping does not work properly in Keras 3 when used in a for loop HOT 8
- Add AdEMAMix Optimizer HOT 4
- ValueError: File not found: filepath=Backend\C4__256g_000040000.keras. Please ensure the file is an accessible `.keras` zip file. HOT 6
- Model weights not saved if a custom layer class contains a list of layers named self._layers HOT 2
- Accessing the current training iteration step in a custom Layer class HOT 4
- Keras v3 equivalent for `get_output_at(num)` HOT 4
- A local file was found, but it seems to be incomplete or outdated because the auto file hash does not match the original value of ...
- Error: ValueError: Cannot get result() since the metric has not yet been built during model.fit() HOT 1
- Incompatibility in 'tf.GradientTape.watch' of TensorFlow 2.17 in Keras 3.4.1 HOT 1
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.