Skip to content

[Fix Request] Execution order for adapter and flatten components in base class #101

@HubertPalo

Description

@HubertPalo

Describe the problem
In current base class implementation, the flatten function is incorrectly applied before the adapter.

Proposed Solution
Update the application order for the flatten and adapter functions in the base class.

Additional Context
Current documentation in base class:

"""
...
The architecture is structured as follows:

        +------------------+
        |  Backbone Model  |
        +------------------+
                |
                v
        +------------------------+
        |  Adapter (Optional)    |
        +------------------------+
                |
         (Flatten if needed)
                v
        +------------------------+
        |  Fully Connected Head  |
        +------------------------+
                |
                v
        +------------------+
        |  Loss Function   |
        +------------------+
...
"""

Meanwhile, in the implementation (lines 192 to 197):

        if self.flatten:
            x = x.reshape(x.size(0), -1)
        if self.adapter is not None:
            x = self.adapter(x)

Steps to Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/discovery-unicamp/Minerva/blob/main/minerva/models/nets/base.py#L193
  2. See the issue

Expected Behavior
Adapters must be applied BEFORE the flatten function.

Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions