Skip to content

Commit

Permalink
Merge pull request #2 from stared/patch-1
Browse files Browse the repository at this point in the history
fix: prints changed to work with python3
  • Loading branch information
tgrel authored Apr 5, 2017
2 parents 940e2eb + 8860c52 commit 3d7c173
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions roi_pooling/roi_pooling_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function

import tensorflow as tf
import numpy as np

Expand Down Expand Up @@ -25,8 +27,8 @@
n_rois = len(rois_value)
y_shape = [n_rois, 1, pool_height, pool_width]

print 'Input: ', input_value, ', shape: ', input_value.shape
print 'ROIs: ', rois_value, ', shape: ', rois_value.shape
print('Input: ', input_value, ', shape: ', input_value.shape)
print('ROIs: ', rois_value, ', shape: ', rois_value.shape)

# precise semantics is now only defined by the kernel, need tests
input = tf.placeholder(tf.float32)
Expand All @@ -36,10 +38,10 @@
mean = tf.reduce_mean(y)

grads = tf.gradients(mean, input)
print type(grads)
print len(grads)
print grads
print input_value.shape
print(type(grads))
print(len(grads))
print(grads)
print(input_value.shape)

with tf.Session('') as sess:
# NOTE(maciek): looks like we have to use consts here, based on tensorflow/python/ops/nn_test.py
Expand All @@ -50,10 +52,10 @@

numerical_grad_error_1 = tf.test.compute_gradient_error([input_const], [input_value.shape], y, y_shape)
numerical_grad_error_2 = tf.test.compute_gradient_error([input_const], [input_value.shape], mean, [])
print numerical_grad_error_1, numerical_grad_error_2
print(numerical_grad_error_1, numerical_grad_error_2)

with tf.Session('') as sess:
y_output = sess.run(y, feed_dict={input: input_value, rois: rois_value})
print 'y: ', y_output
print('y: ', y_output)
grads_output = sess.run(grads, feed_dict={input: input_value, rois: rois_value})
print 'grads: ', grads_output
print('grads: ', grads_output)

0 comments on commit 3d7c173

Please sign in to comment.