1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Deep Learning with PyTorch

Connected

Exercise

Two-input model

With the data ready, it's time to build the two-input model architecture! To do so, you will set up a model class with the following methods:

  • .__init__(), in which you will define sub-networks by grouping layers; this is where you define the two layers for processing the two inputs, and the classifier that returns a classification score for each class.

  • forward(), in which you will pass both inputs through corresponding pre-defined sub-networks, concatenate the outputs, and pass them to the classifier.

torch.nn is already imported for you as nn. Let's do it!

Instructions 1/3

undefined XP
    1
    2
    3
  • Define image, alphabet and classifier sub-networks as sequential models, assigning them to self.image_layer, self.alphabet_layer and self.classifier, respectively.