'module 'tensorflow_estimator.python.estimator.api._v1.estimator' has no attribute 'rnn'
AttributeError: module 'tensorflow_estimator.python.estimator.api._v1.estimator' has no attribute 'rnn' keeps popping up. I am doing a project on Spelling correction and i really can't figure out why this error occured
Part of code where the error is shown:
def encoding_layer(rnn_size, sequence_length, num_layers, rnn_inputs, keep_prob, direction): '''Create the encoding layer'''
if direction == 1:
with tf.name_scope("RNN_Encoder_Cell_1D"):
for layer in range(num_layers):
with tf.compat.v1.variable_scope('encoder_{}'.format(layer)):
lstm = tf.compat.v1.estimator.rnn.LSTMCell(rnn_size)
drop = tf.compat.v1.estimator.rnn.DropoutWrapper(lstm,
input_keep_prob = keep_prob)
enc_output, enc_state = tf.nn.dynamic_rnn(drop,
rnn_inputs,
sequence_length,
dtype=tf.float32)
return enc_output, enc_state
if direction == 2:
with tf.name_scope("RNN_Encoder_Cell_2D"):
for layer in range(num_layers):
with tf.compat.v1.variable_scope('encoder_{}'.format(layer)):
cell_fw = tf.compat.v1.estimator.rnn.LSTMCell(rnn_size)
cell_fw = tf.compat.v1.estimator.rnn.DropoutWrapper(cell_fw,
input_keep_prob = keep_prob)
cell_bw = tf.contrib.rnn.LSTMCell(rnn_size)
cell_bw = tf.contrib.rnn.DropoutWrapper(cell_bw,
input_keep_prob = keep_prob)
enc_output, enc_state = tf.nn.bidirectional_dynamic_rnn(cell_fw,
cell_bw,
rnn_inputs,
sequence_length,
dtype=tf.float32)
# Join outputs since we are using a bidirectional RNN
enc_output = tf.concat(enc_output,2)
# Use only the forward state because the model can't use both states at once
return enc_output, enc_state[0]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
