# chang-cai/taskcommmcr2 architecture

> Architecture diagram of the GitHub repository chang-cai/taskcommmcr2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chang-cai/taskcommmcr2
- Repository: https://github.com/chang-cai/taskcommmcr2

## Overview

TaskCommMCR2 learns multiview image features with Maximal Coding Rate Reduction (MCR²), evaluates learned representations, and extracts features for downstream use; it also provides MATLAB precoding optimization and performance comparison. The principal workflow is phase-one single-view training, phase-two multiview training, then optional feature extraction. Training scripts wire datasets, models, loss, and trainer; the trainer runs optimization and periodic SVM evaluation. MATLAB internals are not excerpted, so that subsystem is represented at its documented entry point and directory level.

Main entry points: [`main_train_phase2.py`](https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase2.py) (Phase-two training), [`feature_load.py`](https://github.com/chang-cai/taskcommmcr2/blob/main/feature_load.py) (Checkpoint extraction), [`tools/trainer.py`](https://github.com/chang-cai/taskcommmcr2/blob/main/tools/trainer.py) (Training orchestration), [`main_train_phase1.py`](https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase1.py) (Phase-one training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Feature training"]
  node_phase1["Phase-one training"]
  node_phase2["Phase-two training"]
  node_mcr2["MCR² objective<br/>[mcr2_loss.py]"]
  node_trainer["Training orchestration<br/>[trainer.py]"]
end

subgraph group_runtime["Model runtime"]
  node_image_data["Image datasets<br/>[img_dataset.py]"]
  node_single_view["Single-view CNN<br/>[mvcnn.py]"]
  node_multi_view["Multiview CNN<br/>[mvcnn.py]"]
  node_model_base["Model persistence<br/>[model.py]"]
end

subgraph group_evaluation["Evaluation and extraction"]
  node_feature_ops["Feature extraction<br/>[train_func.py]"]
  node_svm_eval["SVM evaluation<br/>[evaluate_func.py]"]
  node_feature_load["Checkpoint extraction<br/>[feature_load.py]"]
  node_feature_output["Feature and label output<br/>[feature_load.py]"]
end

subgraph group_communication["Precoding evaluation"]
  node_precoding_entry["Precoding comparison"]
  node_precoding_code["Precoding optimization code"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts"| node_phase1
node_researcher -->|"starts"| node_phase2
node_researcher -->|"runs"| node_feature_load
node_researcher -->|"runs"| node_precoding_entry
node_phase1 -->|"configures"| node_image_data
node_phase1 -->|"creates"| node_single_view
node_phase1 -->|"configures"| node_mcr2
node_phase1 -->|"configures"| node_trainer
node_phase2 -->|"configures"| node_image_data
node_phase2 -->|"creates"| node_single_view
node_phase2 -->|"creates"| node_multi_view
node_phase2 -->|"configures"| node_mcr2
node_phase2 -->|"configures"| node_trainer
node_multi_view -->|"uses"| node_single_view
node_single_view -->|"inherits"| node_model_base
node_multi_view -->|"inherits"| node_model_base
node_trainer -->|"computes loss"| node_mcr2
node_trainer -->|"extracts features"| node_feature_ops
node_trainer -->|"evaluates"| node_svm_eval
node_trainer -->|"saves model"| node_model_base
node_feature_load -->|"loads"| node_image_data
node_feature_load -->|"creates"| node_single_view
node_feature_load -->|"creates"| node_multi_view
node_feature_load -->|"extracts"| node_feature_ops
node_feature_load -->|"produces"| node_feature_output
node_precoding_entry -->|"runs comparison"| node_precoding_code

click node_phase1 "https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase1.py"
click node_phase2 "https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase2.py"
click node_image_data "https://github.com/chang-cai/taskcommmcr2/blob/main/tools/img_dataset.py"
click node_single_view "https://github.com/chang-cai/taskcommmcr2/blob/main/models/mvcnn.py"
click node_multi_view "https://github.com/chang-cai/taskcommmcr2/blob/main/models/mvcnn.py"
click node_model_base "https://github.com/chang-cai/taskcommmcr2/blob/main/models/model.py"
click node_mcr2 "https://github.com/chang-cai/taskcommmcr2/blob/main/mcr2_loss.py"
click node_trainer "https://github.com/chang-cai/taskcommmcr2/blob/main/tools/trainer.py"
click node_feature_ops "https://github.com/chang-cai/taskcommmcr2/blob/main/tools/train_func.py"
click node_svm_eval "https://github.com/chang-cai/taskcommmcr2/blob/main/tools/evaluate_func.py"
click node_feature_load "https://github.com/chang-cai/taskcommmcr2/blob/main/feature_load.py"
click node_feature_output "https://github.com/chang-cai/taskcommmcr2/blob/main/feature_load.py"
click node_precoding_entry "https://github.com/chang-cai/taskcommmcr2/blob/main/precoding_opt_matlab/main_precoding_opt.m"
click node_precoding_code "https://github.com/chang-cai/taskcommmcr2/tree/main/precoding_opt_matlab"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_phase1,node_phase2,node_mcr2,node_trainer toneBlue
class node_image_data,node_single_view,node_multi_view,node_model_base toneAmber
class node_feature_ops,node_svm_eval,node_feature_load,node_feature_output toneMint
class node_precoding_entry,node_precoding_code toneRose
class node_researcher toneIndigo
```

## Components

### Feature training

- [Phase-one training](https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase1.py): `main_train_phase1.py`
- [Phase-two training](https://github.com/chang-cai/taskcommmcr2/blob/main/main_train_phase2.py): `main_train_phase2.py`
- [MCR² objective](https://github.com/chang-cai/taskcommmcr2/blob/main/mcr2_loss.py): `mcr2_loss.py`
- [Training orchestration](https://github.com/chang-cai/taskcommmcr2/blob/main/tools/trainer.py): `tools/trainer.py`

### Model runtime

- [Image datasets](https://github.com/chang-cai/taskcommmcr2/blob/main/tools/img_dataset.py): `tools/img_dataset.py`
- [Single-view CNN](https://github.com/chang-cai/taskcommmcr2/blob/main/models/mvcnn.py): `models/mvcnn.py`
- [Multiview CNN](https://github.com/chang-cai/taskcommmcr2/blob/main/models/mvcnn.py): `models/mvcnn.py`
- [Model persistence](https://github.com/chang-cai/taskcommmcr2/blob/main/models/model.py): `models/model.py`

### Evaluation and extraction

- [Feature extraction](https://github.com/chang-cai/taskcommmcr2/blob/main/tools/train_func.py): `tools/train_func.py`
- [SVM evaluation](https://github.com/chang-cai/taskcommmcr2/blob/main/tools/evaluate_func.py): `tools/evaluate_func.py`
- [Checkpoint extraction](https://github.com/chang-cai/taskcommmcr2/blob/main/feature_load.py): `feature_load.py`
- [Feature and label output](https://github.com/chang-cai/taskcommmcr2/blob/main/feature_load.py): `feature_load.py`

### Precoding evaluation

- [Precoding comparison](https://github.com/chang-cai/taskcommmcr2/blob/main/precoding_opt_matlab/main_precoding_opt.m): `precoding_opt_matlab/main_precoding_opt.m`
- [Precoding optimization code](https://github.com/chang-cai/taskcommmcr2/tree/main/precoding_opt_matlab): `precoding_opt_matlab`

### Other components

- **Researcher**

## Connections

- Researcher → Phase-one training: starts (evidence: `README.md`)
- Researcher → Phase-two training: starts (evidence: `README.md`)
- Researcher → Checkpoint extraction: runs (evidence: `README.md`)
- Researcher → Precoding comparison: runs (evidence: `README.md`)
- Phase-one training → Image datasets: configures (evidence: `main_train_phase1.py`)
- Phase-one training → Single-view CNN: creates (evidence: `main_train_phase1.py`)
- Phase-one training → MCR² objective: configures (evidence: `main_train_phase1.py`)
- Phase-one training → Training orchestration: configures (evidence: `main_train_phase1.py`)
- Phase-two training → Image datasets: configures (evidence: `main_train_phase2.py`)
- Phase-two training → Single-view CNN: creates (evidence: `main_train_phase2.py`)
- Phase-two training → Multiview CNN: creates (evidence: `main_train_phase2.py`)
- Phase-two training → MCR² objective: configures (evidence: `main_train_phase2.py`)
- Phase-two training → Training orchestration: configures (evidence: `main_train_phase2.py`)
- Multiview CNN → Single-view CNN: uses (evidence: `models/mvcnn.py`)
- Single-view CNN → Model persistence: inherits (evidence: `models/mvcnn.py`)
- Multiview CNN → Model persistence: inherits (evidence: `models/mvcnn.py`)
- Training orchestration → MCR² objective: computes loss (evidence: `tools/trainer.py`)
- Training orchestration → Feature extraction: extracts features (evidence: `tools/trainer.py`)
- Training orchestration → SVM evaluation: evaluates (evidence: `tools/trainer.py`)
- Training orchestration → Model persistence: saves model (evidence: `tools/trainer.py`)
- Checkpoint extraction → Image datasets: loads (evidence: `feature_load.py`)
- Checkpoint extraction → Single-view CNN: creates (evidence: `feature_load.py`)
- Checkpoint extraction → Multiview CNN: creates (evidence: `feature_load.py`)
- Checkpoint extraction → Feature extraction: extracts (evidence: `feature_load.py`)
- Checkpoint extraction → Feature and label output: produces (evidence: `feature_load.py`)
- Precoding comparison → Precoding optimization code: runs comparison (evidence: `README.md`)
