Results not matching when running session multiple times
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 |
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 |
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 '18 at 7:51
kvish
56428
56428
asked Nov 22 '18 at 2:13
Satish EdupugantiSatish Edupuganti
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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 '18 at 3:57
kvishkvish
56428
56428
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.
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