Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import tensorflow as tf
  2. import numpy as np
  3.  
  4. a = np.array([1, 3, 7, 1, 2, 6, 0, 1])
  5. peaks = a[1:-1][np.diff(np.diff(a)) < 0]
  6.  
  7. peak_values = tf.Variable(np.nonzero(np.in1d(a, peaks))[0])
  8.  
  9. init = tf.global_variables_initializer()
  10.  
  11. with tf.Session() as session:
  12.     session.run(init)
  13.     print('Peaks are at: ', session.run(peak_values))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement