Results not matching when running session multiple times
up vote
0
down vote
favorite
When i tried to print out1 and out2 i observed that the values coming in out2 doesnt exist in out1. But out2 is just finding the maximum from out1. Need help
import tensorflow as tf
from keras import backend as K
box_class_probs = tf.random_normal([2, 2, 1, 2], mean=1, stddev=4, seed = 1)
max_ind_class=K.max(box_class_probs,axis=-1)
with tf.Session() as sess:
out1=sess.run(box_class_probs)
print(out1)
out2=sess.run(max_ind_class)
print(out2)
output:
[[[[-2.24527287 6.93839502]]
[[ 1.26131749 -8.77081585]]]
[[[ 1.39699364 3.36489725]]
[[ 3.37129188 -7.49171829]]]]
---------------------------------------------
---------------------------------------------
---------------------------------------------
[[[ 1.96837616]
[ 3.06311464]]
[[ 9.33515644]
[ 6.58941841]]]
tensorflow keras
add a comment |
up vote
0
down vote
favorite
When i tried to print out1 and out2 i observed that the values coming in out2 doesnt exist in out1. But out2 is just finding the maximum from out1. Need help
import tensorflow as tf
from keras import backend as K
box_class_probs = tf.random_normal([2, 2, 1, 2], mean=1, stddev=4, seed = 1)
max_ind_class=K.max(box_class_probs,axis=-1)
with tf.Session() as sess:
out1=sess.run(box_class_probs)
print(out1)
out2=sess.run(max_ind_class)
print(out2)
output:
[[[[-2.24527287 6.93839502]]
[[ 1.26131749 -8.77081585]]]
[[[ 1.39699364 3.36489725]]
[[ 3.37129188 -7.49171829]]]]
---------------------------------------------
---------------------------------------------
---------------------------------------------
[[[ 1.96837616]
[ 3.06311464]]
[[ 9.33515644]
[ 6.58941841]]]
tensorflow keras
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When i tried to print out1 and out2 i observed that the values coming in out2 doesnt exist in out1. But out2 is just finding the maximum from out1. Need help
import tensorflow as tf
from keras import backend as K
box_class_probs = tf.random_normal([2, 2, 1, 2], mean=1, stddev=4, seed = 1)
max_ind_class=K.max(box_class_probs,axis=-1)
with tf.Session() as sess:
out1=sess.run(box_class_probs)
print(out1)
out2=sess.run(max_ind_class)
print(out2)
output:
[[[[-2.24527287 6.93839502]]
[[ 1.26131749 -8.77081585]]]
[[[ 1.39699364 3.36489725]]
[[ 3.37129188 -7.49171829]]]]
---------------------------------------------
---------------------------------------------
---------------------------------------------
[[[ 1.96837616]
[ 3.06311464]]
[[ 9.33515644]
[ 6.58941841]]]
tensorflow keras
When i tried to print out1 and out2 i observed that the values coming in out2 doesnt exist in out1. But out2 is just finding the maximum from out1. Need help
import tensorflow as tf
from keras import backend as K
box_class_probs = tf.random_normal([2, 2, 1, 2], mean=1, stddev=4, seed = 1)
max_ind_class=K.max(box_class_probs,axis=-1)
with tf.Session() as sess:
out1=sess.run(box_class_probs)
print(out1)
out2=sess.run(max_ind_class)
print(out2)
output:
[[[[-2.24527287 6.93839502]]
[[ 1.26131749 -8.77081585]]]
[[[ 1.39699364 3.36489725]]
[[ 3.37129188 -7.49171829]]]]
---------------------------------------------
---------------------------------------------
---------------------------------------------
[[[ 1.96837616]
[ 3.06311464]]
[[ 9.33515644]
[ 6.58941841]]]
tensorflow keras
tensorflow keras
edited Nov 22 at 7:51
kvish
36717
36717
asked Nov 22 at 2:13
Satish Edupuganti
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You need to run both of your results in one session run, because you are generating the box_class_probs randomly, and according to the random seed (default or internal), it is going to change every time you execute a session run. And also, keep in mind its always more consistent to get the current keras backend session using K.get_session() and then run your code when you are mixing keras and tensorflow.
sess = K.get_session()
out1, out2 = sess.run([box_class_probs, max_ind_class])
print(out1)
print(out2)
Result:
[[[[-2.2452729 6.938395 ]]
[[ 1.2613175 -8.770817 ]]]
[[[ 1.3969936 3.3648973]]
[[ 3.3712919 -7.4917183]]]]
[[[6.938395 ]
[1.2613175]]
[[3.3648973]
[3.3712919]]]
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You need to run both of your results in one session run, because you are generating the box_class_probs randomly, and according to the random seed (default or internal), it is going to change every time you execute a session run. And also, keep in mind its always more consistent to get the current keras backend session using K.get_session() and then run your code when you are mixing keras and tensorflow.
sess = K.get_session()
out1, out2 = sess.run([box_class_probs, max_ind_class])
print(out1)
print(out2)
Result:
[[[[-2.2452729 6.938395 ]]
[[ 1.2613175 -8.770817 ]]]
[[[ 1.3969936 3.3648973]]
[[ 3.3712919 -7.4917183]]]]
[[[6.938395 ]
[1.2613175]]
[[3.3648973]
[3.3712919]]]
add a comment |
up vote
0
down vote
accepted
You need to run both of your results in one session run, because you are generating the box_class_probs randomly, and according to the random seed (default or internal), it is going to change every time you execute a session run. And also, keep in mind its always more consistent to get the current keras backend session using K.get_session() and then run your code when you are mixing keras and tensorflow.
sess = K.get_session()
out1, out2 = sess.run([box_class_probs, max_ind_class])
print(out1)
print(out2)
Result:
[[[[-2.2452729 6.938395 ]]
[[ 1.2613175 -8.770817 ]]]
[[[ 1.3969936 3.3648973]]
[[ 3.3712919 -7.4917183]]]]
[[[6.938395 ]
[1.2613175]]
[[3.3648973]
[3.3712919]]]
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You need to run both of your results in one session run, because you are generating the box_class_probs randomly, and according to the random seed (default or internal), it is going to change every time you execute a session run. And also, keep in mind its always more consistent to get the current keras backend session using K.get_session() and then run your code when you are mixing keras and tensorflow.
sess = K.get_session()
out1, out2 = sess.run([box_class_probs, max_ind_class])
print(out1)
print(out2)
Result:
[[[[-2.2452729 6.938395 ]]
[[ 1.2613175 -8.770817 ]]]
[[[ 1.3969936 3.3648973]]
[[ 3.3712919 -7.4917183]]]]
[[[6.938395 ]
[1.2613175]]
[[3.3648973]
[3.3712919]]]
You need to run both of your results in one session run, because you are generating the box_class_probs randomly, and according to the random seed (default or internal), it is going to change every time you execute a session run. And also, keep in mind its always more consistent to get the current keras backend session using K.get_session() and then run your code when you are mixing keras and tensorflow.
sess = K.get_session()
out1, out2 = sess.run([box_class_probs, max_ind_class])
print(out1)
print(out2)
Result:
[[[[-2.2452729 6.938395 ]]
[[ 1.2613175 -8.770817 ]]]
[[[ 1.3969936 3.3648973]]
[[ 3.3712919 -7.4917183]]]]
[[[6.938395 ]
[1.2613175]]
[[3.3648973]
[3.3712919]]]
answered Nov 22 at 3:57
kvish
36717
36717
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422978%2fresults-not-matching-when-running-session-multiple-times%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown