unable to convert tf.contrib.layers.embed_sequence in Tensorflow 2 code

Viewed 269

This is the function where encoding layer is defined. I want to migrate my code to Tensorflow 2.0 and im stuck here.

def encoding_layer(rnn_inputs, rnn_size, num_layers, keep_prob, 
                   source_vocab_size, 
                   encoding_embedding_size):

     embed = tf.contrib.layers.embed_sequence(rnn_inputs, 
                                              vocab_size=source_vocab_size, 
                                              embed_dim=encoding_embedding_size)

    stacked_cells = tf.compat.v1.nn.rnn_cell.MultiRNNCell([tf.contrib.rnn.DropoutWrapper(tf.compat.v1.nn.rnn_cell.LSTMCell(rnn_size), keep_prob) for _ in range(num_layers)])

    outputs, state = tf.compat.v1.nn.dynamic_rnn(stacked_cells, 
                                       embed, 
                                       dtype=tf.float32)

    return outputs, state

I tried to use tf.keras.layers.Embeddings but not sure how to stack all of this into that.

0 Answers
Related