Tensorflow median value
How can I calculate the median value of a list in tensorflow? Like node = tf.median(X) X is the placeholder In numpy, I can directly use np.median to get the median value. How can I use the numpy operation in tensorflow?
No need to use the numpy function. You can calculate the median inside tensorflow using: def get_median(v): v = tf.reshape(v, [-1]) m = v.get_shape()//2 return tf.nn.top_k(v, m).values[m-1] If X is already a vector you can skip the reshaping.
There is currently no median function in TF. The only way to use numpy operation in TF is after you run your graph: import tensorflow as tf import numpy as np a = tf.random_uniform(shape=(5, 5)) with tf.Session() as sess: np_matrix = sess.run(a) print np.median(np_matrix)
python-shell on linux system indentation error
How come 1 is printed instead of 0?
How to subtracting two hyperspectral image?
Getting an error: list assignment index out of range
Launching dev_appserver.py from windows powershell gives me “too few arguments” error
How do you split all of a certain character in Python [duplicate]
Issues with data types in pandas functions
Firebase Console but there is error tell “Error Generating Download URL”
Python Twitter Streaming Timeline
Interval intersection in pandas
Putting double quotes for an output string
How to query with raw SQL using Session or engine
getUser return EDAMSystemException errorCode=8
How to print the subject of a single email using uid
Avoiding Python globals in Google App/Cloud Engine
Python Google Voice get texts from [number]