Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

TF v2 support for Recurrent/Bidirectional #607

Closed
@cjermain

Description

@cjermain

@DronistB posted an issue on #413 showing that the new TensorFlow V2 API for Keras does not work with the existing conversion code for Bidirectional RNN layers. This occurs because TensorFlow's new RNN layers are in a different module (tensorflow.python.keras.layers.recurrent_v2). At a minimum, the following code will need to change to support the TensorFlow versions as well as the conventional Keras classes.

@cvtfunc(shape_infer=_calculate_keras_bidirectional_output_shapes)
def convert_bidirectional(scope, operator, container):
op_type = type(operator.raw_operator.forward_layer)
bidirectional = True
if op_type == keras.layers.LSTM:
lstm.convert_keras_lstm(scope, operator, container, bidirectional)
elif op_type == keras.layers.GRU:
gru.convert_keras_gru(scope, operator, container, bidirectional)
elif op_type == keras.layers.SimpleRNN:
simplernn.convert_keras_simple_rnn(scope, operator, container, bidirectional)
else:
raise ValueError('Unsupported class for Bidirectional layer: {}'.format(op_type))

Happy to take a look at resolving this when I have bandwidth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions