Code Monkey home page Code Monkey logo

Comments (6)

HiKapok avatar HiKapok commented on September 28, 2024

@xtanitfy It's quite easy to debug or view the contents of some tensors by tensorflow, e.g. tf.Print, tf.Debug, or you can use tf.py_func to wrap any function in python with anything you can do.

from ssd.tensorflow.

xtanitfy avatar xtanitfy commented on September 28, 2024

Thank you very much!
But with the callback of tf.estimator, what time do I print by using tf.Print or tf.Debug?

from ssd.tensorflow.

HiKapok avatar HiKapok commented on September 28, 2024

@xtanitfy there is no necessary to use callback, you can place tf.Print anywhere in you codes

from ssd.tensorflow.

xtanitfy avatar xtanitfy commented on September 28, 2024

I think i can use tf.py_func to dispose of any tensor。Thanks!

from ssd.tensorflow.

xtanitfy avatar xtanitfy commented on September 28, 2024

def my_function(array1, array2):
return array1 + array2, array1 - array2, array1 * array2, np.dot(array1, array2)

def debug_value(array,name):
with open(name+'.txt','w') as f:
f.write(str(array))
return array

if name == 'main':
array1 = np.array([[1, 2], [3, 4]])
array2 = np.array([[5, 6], [7, 8]])

a1 = tf.placeholder(dtype=tf.float32, shape=[2, 2], name='array1')
a2 = tf.placeholder(dtype=tf.float32, shape=[2, 2], name='array2')
b1 = a1 * 2

b1 = tf.py_func(debug_value,[b1,'b1'],[tf.float32])
y1, y2, y3, y4 = tf.py_func(my_function, [b1, a2], [tf.float32, tf.float32, tf.float32, tf.float32])
    
with tf.Session() as sess:
    tf.global_variables_initializer().run()
    _y1, _y2, _y3, _y4 = sess.run([y1, y2, y3, y4], feed_dict={a1: array1, a2: array2})
    print(_y1)
    print('*' * 8)
    print(_y2)
    print('*' * 8)
    print(_y3)
    print('*' * 8)
    print(_y4)

from ssd.tensorflow.

xtanitfy avatar xtanitfy commented on September 28, 2024

I use this way to debug the value.

from ssd.tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.