How to feed the output of a neural network into another neural network?

username: eFroD
cooked: <p>Hello,<br>
this question might sound strange but I couldn’t find information about my use case.<br>
My goal is to combine two different neural networks. The first one is running, it gets an image and classifies it. Now I want to feed this output into another network in order to classify a subcategory of this image.<br>
Concrete this means that the first net can classify a buch of flowers and trees, e.g Rose or Palm Tree. The next net should now classify any kind of tree as “tree” and any kind of flower as "flower.</p>
<p>I have got the labels and the output-tensors but the problem is, that these tensors are no images, so they have only 3 dimensions, since they are missing size parameters.<br>
Now I don’t know if there is a more generic net structure to provide just the training on tensors without the image dimensions because I think that convolutional networks are not the right approach.</p>
<p>I wrote a data loader to provide inputs and lables in the following structure:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/3/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097.png" data-download-href="https://discuss.pytorch.org/uploads/default/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097" title="24"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/3/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097_2_517x285.png" alt="24" data-base62-sha1="6S8nIB8yeybgLmeCQFoX6Leer2v" width="517" height="285" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/3/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097_2_517x285.png, https://discuss.pytorch.org/uploads/default/optimized/2X/3/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097_2_775x427.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/3/302b9fbe72ada04d79a6d1b6d6c03895d9b0d097_2_1034x570.png 2x" data-dominant-color="EEEEEE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">24</span><span class="informations">1252×692 55.2 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
Those are seven output tensors, that should be represented in two different classes.</p>
<p>In this case, all of the input tensors are flowers, so the labels are structured as flowers:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/1/1167809e9833fda6c2dd05895d14470fbf260c5c.png" alt="33" data-base62-sha1="2tXRVVPOpmfM7vW3AsgYV1eM976" width="266" height="18"></p>
<p>I defined flowers as 0 and trees as 1.<br>
If I try to feed this input into a pre-trained model, it is missing a dimension, my own networks are also failing and I wonder where to start.</p>
<p>Thank you very much in advance.</p>

username: ptrblck
cooked: <p>If I understand the use case correctly, you would like to get the general classes based on sub-categories from another model.<br>
If that’s the case, wouldn’t a simple mapping just work, i.e. check for the predicted class and apply a mapping to get the more general class (tree, flower)?</p>
<p>I can imagine the opposite use case might work with a staged model, but I’m not sure if a simple if-condition couldn’t work “perfectly” here.</p>
<p>Let me know, if I misunderstood your use case.</p>

username: eFroD
cooked: <p>Thank you for your answer.</p>
<p>Yes that is exactly what I want but I would like to implement it as a neural network. At this stadium it would not make much sense, since it will be a prototype for future use. Later I want to do multiple classifications on different levels, so i thought of a simple task to get started with the problem. And that is why I try to generalize subclasses.</p>
<p>Is there any way to solve it at this way?</p>