-3

I'm define a class for CNN as follow. Then I execute the code and get IndentationError: expected an indented block. Could you please elaborate where I got wrong?

class Lenet_like:
    """
    Lenet like architecture.
    """
    def __init__(self, width, depth, drop, n_classes):
    """
    Architecture settings.

    Arguments:
      - width: int, first layer number of convolution filters.
      - depth: int, number of convolution layer in the network.
      - drop: float, dropout rate.
      - n_classes: int, number of classes in the dataset.
    """
        self.width = width
        self.depth = depth
        self.drop = drop
        self.n_classes = n_classes

    def __call__(self, X):
    """
    Call classifier layers on the inputs.
    """

        for k in range(self.depth):
            # Apply successive convolutions to the input !
            # Use the functional API to do so
            X = Conv2D(filters = self.width / (2 ** k), activation = 'relu')(X)
            X = MaxPooling2D(strides = (2, 2))(X)
            X = Dropout(self.drop)(X)

        # Perceptron
        # This is the classification head of the classifier
        X = Flatten(X)
        Y = Dense(units = self.n_classes, activation = 'softmax')(X)

        return Y

Error message:

  File "<ipython-input-1-b8f76520d2cf>", line 16
    """
    ^
IndentationError: expected an indented block
Akira
  • 2,594
  • 3
  • 20
  • 45

1 Answers1

1

A doc string isn't a comment from the point of view of the parser. It's an ordinary expression statement, and as such must be indented like any other part of the def statement's body.

chepner
  • 497,756
  • 71
  • 530
  • 681