Open AndriCcos opened 3 years ago
To answer my question, this can be achieved by running the following code. Make sure to set mode to eval as otherwise it will not work as intended.
model = trax.models.Transformer( input_vocab_size=32768, d_model=512, d_ff=1024, n_heads=8, n_encoder_layers=6, n_decoder_layers=6, max_len=1024, mode='eval' )
model.init_from_file( model_folder+'/model.pkl.gz' )
keras_layer = trax.AsKeras(model, batch_size=1) inputs = tf.keras.Input(shape=(1024,), dtype='int32') hidden = keras_layer((inputs, inputs))
outputs = hidden keras_model = tf.keras.Model(inputs=inputs, outputs=outputs)
Description
I would like to export trax trained model as tf object, to serve it in tensorflow serving ...
Environment information
For bugs: reproduction and error logs