Results not matching when running session multiple times












0















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]]]









share|improve this question





























    0















    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]]]









    share|improve this question



























      0












      0








      0








      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]]]









      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 7:51









      kvish

      56428




      56428










      asked Nov 22 '18 at 2:13









      Satish EdupugantiSatish Edupuganti

      82




      82
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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]]]





          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            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]]]





            share|improve this answer




























              0














              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]]]





              share|improve this answer


























                0












                0








                0







                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]]]





                share|improve this answer













                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]]]






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 3:57









                kvishkvish

                56428




                56428
































                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                    Alcedinidae

                    Can an atomic nucleus contain both particles and antiparticles? [duplicate]