Closed loretoparisi closed 4 years ago
Currently model.predict does not take a dataset but only takes tensors. You could however use functions like map custom loop to call the predict function of your loaded model with a realized tensor. You can use the other dataset methods to set up a pipeline to stream the data from disk. The generator function is probably the most flexible way to create a dataset from file streams (we don't have a built in utility to stream data from files in node).
cc @kangyizhang in case i missed anything/got anything wrong.
To clarify my message a bit the function passed to tf.data.generator would need to do the work that **audio_adapter.load_tf_waveform
does after opening the files that you want (you can chain generators if you want).
Like Yannick said, the current model.predict
function in tfjs does not take a dataset as input. One option is to modify the model in python and change the input format as a tensor, then export the model.
closing this issue , feel free to reopen if you need more info.
@rthadur @kangyizhang @tafsiri thank you very much for your help, I get the big picture, but it is still pretty hard to figure out how to actually implement it. An example related to tf.Dataset
and audio files would be worth, thanks a lot.
Is there a feature request to add tf.data.Dataset
as a supported input type for model.predict
? In the meantime, I guess we usetf.stack
and handle pre-loading ourselves? Is it worth looking at the Keras model.predict
as an example of how to implement tf.data.Dataset
support inmodel.predict
?
TensorFlow.js version
latest version
Node version
Describe the problem or feature request
In my python code I have a
tf.data.Dataset
where a file list is mapped to atf.py_function
:When I load the model into
tfjs
with the newtf.node.loadSavedModel
I get the model with the following signature:When in python the predict takes the dataset as input:
How load a this dataset format into tfjs
model.predict
?Code to reproduce the bug / link to feature request
-