How to apply only 3 layers of a network to a data Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsFirst layer weights for transfer learning with new input tensor in keras.applications models?Keras LSTM: use weights from Keras model to replicate predictions using numpy“concat” mode can only merge layers with matching output shapes except for the concat axisMulti task learning in KerasIs it possible to integrate Keras and TensorFlow code?What are the consequences of not freezing layers in transfer learning?Two-class classification model with multi-type input dataAccessing and Multiplying Individual Elements of a Layer's Output in KerasUsing categorial_crossentropy to train a model in kerasError: keras merge LSTM layers in sum mode

Put R under double integral

Is CEO the "profession" with the most psychopaths?

In musical terms, what properties are varied by the human voice to produce different words / syllables?

How to unroll a parameter pack from right to left

Is it possible to force a specific program to remain in memory after closing it?

One-one communication

How to draw/optimize this graph with tikz

How do I find out the mythology and history of my Fortress?

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

Strange behavior of Object.defineProperty() in JavaScript

Can you explain what "processes and tools" means in the first Agile principle?

Random body shuffle every night—can we still function?

Is there any word for a place full of confusion?

Google .dev domain strangely redirects to https

What does Turing mean by this statement?

Most bit efficient text communication method?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Why are vacuum tubes still used in amateur radios?

What is the meaning of 'breadth' in breadth first search?

Is there public access to the Meteor Crater in Arizona?

Why weren't discrete x86 CPUs ever used in game hardware?

What to do with repeated rejections for phd position

Proof of work - 51% attack

Do wooden building fires get hotter than 600°C?



How to apply only 3 layers of a network to a data



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsFirst layer weights for transfer learning with new input tensor in keras.applications models?Keras LSTM: use weights from Keras model to replicate predictions using numpy“concat” mode can only merge layers with matching output shapes except for the concat axisMulti task learning in KerasIs it possible to integrate Keras and TensorFlow code?What are the consequences of not freezing layers in transfer learning?Two-class classification model with multi-type input dataAccessing and Multiplying Individual Elements of a Layer's Output in KerasUsing categorial_crossentropy to train a model in kerasError: keras merge LSTM layers in sum mode










1












$begingroup$


I want to use the 3rd layer's output of the VGG16 network. The error is like below:



UserWarning: Model inputs must come from `keras.layers.Input` (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to your model was not an Input tensor, it was generated by layer input_1.
Note that input tensors are instantiated via `tensor = keras.layers.Input(shape)`.
The tensor that caused the issue was: input_1:0
str(x.name))
Traceback (most recent call last):


The code I'm using is below:



from keras import Model
from keras import applications

vgg_model = applications.VGG16(include_top=True, weights='imagenet')
vgg_model.summary()
layers = [l for l in vgg_model.layers]

first_layers = layers[0:3]

result_model = Model(input=layers[0].input, output=first_layers[2](first_layers[1](first_layers[0](layers[0].input))))
print("success")
result_model.summary()


My eventual goal is to take this output and send it to another process and it will continue from 4th layer.



How can I split the neural network into two like this?










share|improve this question









$endgroup$
















    1












    $begingroup$


    I want to use the 3rd layer's output of the VGG16 network. The error is like below:



    UserWarning: Model inputs must come from `keras.layers.Input` (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to your model was not an Input tensor, it was generated by layer input_1.
    Note that input tensors are instantiated via `tensor = keras.layers.Input(shape)`.
    The tensor that caused the issue was: input_1:0
    str(x.name))
    Traceback (most recent call last):


    The code I'm using is below:



    from keras import Model
    from keras import applications

    vgg_model = applications.VGG16(include_top=True, weights='imagenet')
    vgg_model.summary()
    layers = [l for l in vgg_model.layers]

    first_layers = layers[0:3]

    result_model = Model(input=layers[0].input, output=first_layers[2](first_layers[1](first_layers[0](layers[0].input))))
    print("success")
    result_model.summary()


    My eventual goal is to take this output and send it to another process and it will continue from 4th layer.



    How can I split the neural network into two like this?










    share|improve this question









    $endgroup$














      1












      1








      1


      1



      $begingroup$


      I want to use the 3rd layer's output of the VGG16 network. The error is like below:



      UserWarning: Model inputs must come from `keras.layers.Input` (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to your model was not an Input tensor, it was generated by layer input_1.
      Note that input tensors are instantiated via `tensor = keras.layers.Input(shape)`.
      The tensor that caused the issue was: input_1:0
      str(x.name))
      Traceback (most recent call last):


      The code I'm using is below:



      from keras import Model
      from keras import applications

      vgg_model = applications.VGG16(include_top=True, weights='imagenet')
      vgg_model.summary()
      layers = [l for l in vgg_model.layers]

      first_layers = layers[0:3]

      result_model = Model(input=layers[0].input, output=first_layers[2](first_layers[1](first_layers[0](layers[0].input))))
      print("success")
      result_model.summary()


      My eventual goal is to take this output and send it to another process and it will continue from 4th layer.



      How can I split the neural network into two like this?










      share|improve this question









      $endgroup$




      I want to use the 3rd layer's output of the VGG16 network. The error is like below:



      UserWarning: Model inputs must come from `keras.layers.Input` (thus holding past layer metadata), they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to your model was not an Input tensor, it was generated by layer input_1.
      Note that input tensors are instantiated via `tensor = keras.layers.Input(shape)`.
      The tensor that caused the issue was: input_1:0
      str(x.name))
      Traceback (most recent call last):


      The code I'm using is below:



      from keras import Model
      from keras import applications

      vgg_model = applications.VGG16(include_top=True, weights='imagenet')
      vgg_model.summary()
      layers = [l for l in vgg_model.layers]

      first_layers = layers[0:3]

      result_model = Model(input=layers[0].input, output=first_layers[2](first_layers[1](first_layers[0](layers[0].input))))
      print("success")
      result_model.summary()


      My eventual goal is to take this output and send it to another process and it will continue from 4th layer.



      How can I split the neural network into two like this?







      neural-network deep-learning keras tensorflow vgg16






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 2 at 16:29









      AnilAnil

      1112




      1112




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fdatascience.stackexchange.com%2fquestions%2f48458%2fhow-to-apply-only-3-layers-of-a-network-to-a-data%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Data Science Stack Exchange!


          • 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.

          Use MathJax to format equations. MathJax reference.


          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%2fdatascience.stackexchange.com%2fquestions%2f48458%2fhow-to-apply-only-3-layers-of-a-network-to-a-data%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

          Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

          Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

          Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High