Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TimeSeriesDropout_graph = tf.Graph()
- with TimeSeriesDropout_graph.as_default():
- keep_prob_input_default = np.array(1.0,dtype='float32')
- keep_prob_input = tf.placeholder_with_default(keep_prob_input_default,shape=())
- keep_prob_state_default = np.array(1.0,dtype='float32')
- keep_prob_state = tf.placeholder_with_default(keep_prob_state_default,shape=())
- # keep_prob_input = 0.5
- # keep_prob_state = 0.5
- X = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_inputs))
- y = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_outputs))
- multiple_rnn_cell = [tf.keras.layers.SimpleRNNCell(units=n_neurons,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- ,tf.keras.layers.SimpleRNNCell(units=n_neurons//2,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- ,tf.keras.layers.SimpleRNNCell(units=n_neurons//4,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- ,tf.keras.layers.SimpleRNNCell(units=n_neurons//8,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)]
- stacked_rnn_cell = tf.keras.layers.StackedRNNCells(multiple_rnn_cell)
- rnn_output = tf.keras.layers.RNN(stacked_rnn_cell,return_sequences=True,return_state=True)(X)
- outputs_reshaped = tf.reshape(rnn_output[0],(-1,n_neurons//8))
- output = tf.keras.layers.Dense(units=n_outputs)(outputs_reshaped)
- output_stacked = tf.reshape(output,(-1,n_steps,n_outputs))
- loss = tf.reduce_mean(tf.square(y-output_stacked))
- optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
- training_op = optimizer.minimize(loss)
- init = tf.global_variables_initializer()
- saver = tf.train.Saver()
- TypeError Traceback (most recent call last)
- <ipython-input-29-fd7e00c85d84> in <module>()
- 8 X = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_inputs))
- 9 y = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_outputs))
- ---> 10 multiple_rnn_cell = [tf.keras.layers.SimpleRNNCell(units=n_neurons,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- 11 ,tf.keras.layers.SimpleRNNCell(units=n_neurons//2,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- 12 ,tf.keras.layers.SimpleRNNCell(units=n_neurons//4,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
- 1 frames
- /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in __bool__(self)
- 651 `TypeError`.
- 652 """
- --> 653 raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "
- 654 "Use `if t is not None:` instead of `if t:` to test if a "
- 655 "tensor is defined, and use TensorFlow ops such as "
- TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement