# lll2657/omrep architecture

> Architecture diagram of the GitHub repository lll2657/omrep, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lll2657/omrep
- Repository: https://github.com/lll2657/omrep

## Overview

##### Main Components and Their Roles
- Data/Dataset Handling: Both the ANML and OMREP directories include a datasets submodule. These components handle data loading, task sampling, and processing for datasets such as Omniglot, Mini-ImageNet, and CIFAR-FS.
- Model Modules: Both parts have model directories that contain learner definitions, meta-learner modules, and a ModelFactory that creates networks for meta-training/meta-testing. In OMREP, additional initialization functions (e.g., initialize_layers.py) are present.
- Experiment Management: Separate experiment folders are provided for running meta-training procedures. This component orchestrates the meta-learning loops, specifying inner loops (tasks, update steps) and outer loops (meta-updates).
- Evaluation and Visualization: Standalone scripts for evaluation (evaluate_*.py), t-SNE visualization (tsne_*.py), and K-NN testing (knn_*.py) tie into the training pipelines to assess performance.
- Configurations (OMREP only): The OMREP branch includes a configuration directory that holds parsing logic (class_parser.py and related files) that helps set up the experiments or choose meta-learning methods.

##### Relationships and Data Flow
- Data flow starts from the dataset loader: raw input images and CSV splits are parsed in the datasets folders.
- The experiments then call the model components (through model factories) to create learners and meta-learners, which perform inner and outer loop learning.
- Evaluation and visualization scripts sample from the trained models and data representations to create performance metrics and plots (for t-SNE and classification accuracy).

##### Architectural Patterns and Design Principles
- Modular Separation: The clear separation into datasets, experiment, model, and utility directories reflects a modular design that supports experimenting with different meta-learning strategies.
- Reusability and Extensibility: The existence of factory and utils modules is an indicator of design for extensibility (for example, easy to add new datasets or meta-training methods).

##### Relevant Technologies
- The system is built on Python and makes use of key libraries such as PyTorch (with torch and torchvision), NumPy, and TensorFlow (used for some tensorboard or auxiliary tasks).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    ED["External Libraries (PyTorch,NumPy,TensorFlow)"]:::external

    %% ANML Pipeline
    subgraph "ANML Pipeline"
        A1["ANML Datasets"]:::datasets
        A2["ANML Experiment"]:::experiment
        A3["ANML Model Modules"]:::model
        A4["ANML Utilities"]:::utils
        A5["ANML Evaluation & Visualization"]:::eval
    end

    %% OMREP Pipeline
    subgraph "OMREP Pipeline"
        O1["OMREP Datasets"]:::datasets
        O2["OMREP Experiment"]:::experiment
        O3["OMREP Configurations"]:::config
        O4["OMREP Model Modules"]:::model
        O5["OMREP Utilities"]:::utils
        O6["OMREP Evaluation & Visualization"]:::eval
    end

    %% Common Memory Buffer
    MB["Memory Buffer (Latent Experience Replay)"]:::memBuffer

    %% ANML Flow Connections
    A1 -->|"feeds"| A2
    A2 -->|"orchestrates"| A3
    A4 --> A3
    A3 -->|"saves-reps-to"| MB
    MB -->|"replays-to"| A3
    A3 -->|"triggers"| A5
    A5 -->|"feedback"| A2

    %% OMREP Flow Connections
    O1 -->|"feeds"| O2
    O2 -->|"configures"| O3
    O3 -->|"initializes"| O4
    O5 --> O4
    O4 -->|"saves-reps-to"| MB
    MB -->|"replays-to"| O4
    O4 -->|"triggers"| O6
    O6 -->|"feedback"| O2

    %% External Dependencies Connections
    ED --> A3
    ED --> O4

    %% Click Events for ANML Components
    click A1 "https://github.com/lll2657/omrep/tree/main/ANML/datasets"
    click A2 "https://github.com/lll2657/omrep/tree/main/ANML/experiment"
    click A3 "https://github.com/lll2657/omrep/tree/main/ANML/model"
    click A4 "https://github.com/lll2657/omrep/tree/main/ANML/utils"
    click A5 "https://github.com/lll2657/omrep/blob/main/ANML/evaluate_cifar_fs.py"

    %% Click Events for OMREP Components
    click O1 "https://github.com/lll2657/omrep/tree/main/OMREP/datasets"
    click O2 "https://github.com/lll2657/omrep/tree/main/OMREP/experiment"
    click O3 "https://github.com/lll2657/omrep/tree/main/OMREP/configs"
    click O4 "https://github.com/lll2657/omrep/tree/main/OMREP/model"
    click O5 "https://github.com/lll2657/omrep/tree/main/OMREP/utils"
    click O6 "https://github.com/lll2657/omrep/blob/main/OMREP/evaluate_er_*.py"

    %% Styles
    classDef datasets fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef experiment fill:#FADBD8,stroke:#943126,stroke-width:2px;
    classDef model fill:#FDEBD0,stroke:#7D6608,stroke-width:2px;
    classDef eval fill:#D6EAF8,stroke:#1A5276,stroke-width:2px;
    classDef utils fill:#EBDEF0,stroke:#6C3483,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef memBuffer fill:#FDEDEC,stroke:#CB4335,stroke-width:2px;
    classDef external fill:#F0F3F4,stroke:#616A6B,stroke-width:2px;
    
    class A1,A2,A3,A4,A5 external;
    class O1,O2,O3,O4,O5,O6 external;
    
    %% Override colors for ANML and OMREP branches
    class A1,A2,A3,A4,A5 fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    class O1,O2,O3,O4,O5,O6 fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    
    %% Ensuring subgraph nodes retain their specific type styles
    class A1,O1 datasets;
    class A2,O2 experiment;
    class A3,O4 model;
    class A4,O5 utils;
    class A5,O6 eval;
    class O3 config;
```
