I have a weird error when I want to return a train...
# flyte-support
s
I have a weird error when I want to return a trained
keras.Model
(or a
keras.Sequential
) from a task:
Copy code
ValueError: Failed to convert outputs of task 'src.training.train_model.train_model' at position 0.
    Failed to convert type <class 'keras.src.models.sequential.Sequential'> to type <class 'keras.src.models.sequential.Sequential'>.
    Error Message: Invalid filepath extension for saving. Please add either a `.keras` extension for the native Keras format (recommended) or a `.h5` extension. Use `model.export(filepath)` if you want to export a SavedModel for use with TFLite/TFServing/etc. Received: filepath=/tmp/flytevounvueb/local_flytekit/6db7fff3d645ff2970ff0d578df334bc..
It seems like the filepath is missing an extension such as
.keras
. Is this a bug that I can't return a
keras.Model
from a task?
The example in https://www.union.ai/docs/flyte/user-guide/data-input-output/tensorflow/ does not work and results in the same error. The task can't return a
keras.Model
. How can I fix this?
I was able to implement a workaround using
FlyteFile
for the model file instead of the model itself. But this requires that the follow-up tasks load the model from the file every time which is not ideal
t
how large is the model?
please keep in mind one of the premises of flyte is that the data in between tasks is persisted.
this was done to deliberately add immutability and durability
s
I was testing it with the example code (from the link above). It's not big. For our use-case around 2mb at most
t
yeah that’s too large to be stored in-line (i.e. along with primitives like strings and ints). you can add a type transformer if you want… but the net effect of that will be that it’s still a file.
s
Okay, fair. That would be good to know from the docs as I think that it is quite a common issue then.