Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. TimeSeriesDropout_graph = tf.Graph()
  2. with TimeSeriesDropout_graph.as_default():
  3. keep_prob_input_default = np.array(1.0,dtype='float32')
  4. keep_prob_input = tf.placeholder_with_default(keep_prob_input_default,shape=())
  5. keep_prob_state_default = np.array(1.0,dtype='float32')
  6. keep_prob_state = tf.placeholder_with_default(keep_prob_state_default,shape=())
  7. # keep_prob_input = 0.5
  8. # keep_prob_state = 0.5
  9. X = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_inputs))
  10. y = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_outputs))
  11. multiple_rnn_cell = [tf.keras.layers.SimpleRNNCell(units=n_neurons,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  12. ,tf.keras.layers.SimpleRNNCell(units=n_neurons//2,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  13. ,tf.keras.layers.SimpleRNNCell(units=n_neurons//4,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  14. ,tf.keras.layers.SimpleRNNCell(units=n_neurons//8,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)]
  15. stacked_rnn_cell = tf.keras.layers.StackedRNNCells(multiple_rnn_cell)
  16. rnn_output = tf.keras.layers.RNN(stacked_rnn_cell,return_sequences=True,return_state=True)(X)
  17. outputs_reshaped = tf.reshape(rnn_output[0],(-1,n_neurons//8))
  18. output = tf.keras.layers.Dense(units=n_outputs)(outputs_reshaped)
  19. output_stacked = tf.reshape(output,(-1,n_steps,n_outputs))
  20. loss = tf.reduce_mean(tf.square(y-output_stacked))
  21. optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
  22. training_op = optimizer.minimize(loss)
  23. init = tf.global_variables_initializer()
  24. saver = tf.train.Saver()
  25.  
  26. TypeError Traceback (most recent call last)
  27. <ipython-input-29-fd7e00c85d84> in <module>()
  28. 8 X = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_inputs))
  29. 9 y = tf.placeholder(dtype=tf.float32,shape=(None,n_steps,n_outputs))
  30. ---> 10 multiple_rnn_cell = [tf.keras.layers.SimpleRNNCell(units=n_neurons,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  31. 11 ,tf.keras.layers.SimpleRNNCell(units=n_neurons//2,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  32. 12 ,tf.keras.layers.SimpleRNNCell(units=n_neurons//4,activation='relu',dropout=keep_prob_input,recurrent_dropout=keep_prob_state)
  33.  
  34. 1 frames
  35. /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in __bool__(self)
  36. 651 `TypeError`.
  37. 652 """
  38. --> 653 raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "
  39. 654 "Use `if t is not None:` instead of `if t:` to test if a "
  40. 655 "tensor is defined, and use TensorFlow ops such as "
  41.  
  42. 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