python


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()[0]//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)

Related Links

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]

Categories

HOME
tensorflow
laravel-5
google-apps-script
dotnetrdf
sass
npm
vb6
scipy
vs-team-services
ruby-on-rails-3
concourse
defragmentation
jrebel
user
file-io
i2c
openwrt
height
criteria
cortex-a
intellij-plugin
dryioc
game-physics
automata
mongodb-query
dlib
local
ida
uisplitviewcontroller
mule-studio
tree-traversal
styles
statusbar
hhvm
cocoa-touch
jflex
osmdroid
thinking-sphinx
vertex-buffer
lmdb
smart-mobile-studio
fractals
rhomobile
nsurlconnection
bing-maps-api
mms
xamarin.uitest
deepstream.io
android-preferences
wcf-security
finite-element-analysis
stress-testing
encapsulation
rapidweaver
ideone
web-deployment-project
pinvoke
multi-agent
workflow-foundation-4.5
infinite-scroll
selenium-firefoxdriver
redux-router
webkit2
gradle-release-plugin
financial
insertion-sort
hateoas
hyperthreading
graphical-logo
named-ranges
candidate-key
and-operator
vcl
wss
ssms-addin
data-generation
gamepad
convex-polygon
nuspec
grunt-contrib-compass
prng
cgpath
bulbs
git-filter-branch
javascriptserializer
radchart
redirectstandardoutput
jpf
supersized
tcxgrid
gtk2hs
nvelocity
email-spec
exitstatus
rtsp-client
multibyte-functions
lazy-c++
web-analytics-tools
database-diagramming
data-execution-prevention

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App