from bioMONAI.data import *
from bioMONAI.transforms import *
from bioMONAI.core import *
from bioMONAI.core import Path
from bioMONAI.data import *
from bioMONAI.nets import BasicUNet, DynUNet
from bioMONAI.losses import *
from bioMONAI.losses import SSIMLoss
from bioMONAI.metrics import *
from bioMONAI.datasets import download_file, split_dataframe, add_columns_to_csv
import os
Multispectral Classification
Setup imports
import warnings
"ignore") warnings.filterwarnings(
= get_device()
device print(device)
cuda
Download dataset
In the next cell, we will download a subset of the RXRX1 dataset from the MONAI repository. This dataset contains multispectral images that we will use for our classification task. The download_file
function is used to download and extract the dataset to a specified directory.
- The dataset URL is specified, and a hash is provided to ensure data integrity.
- The
extract
parameter is set toTrue
to automatically extract the downloaded zip file. - The
extract_dir
parameter is left empty, meaning the contents will be extracted to the specified directory.
- You can change the
url
variable to point to a different dataset if needed.- Modify the
extract_dir
parameter to specify a different extraction directory.- Ensure that the
hash
value matches the dataset you are downloading to avoid data corruption issues.
# Define the base URL for the dataset
= "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/rxrx1_subset_monai.zip"
url
"../_data", extract=True, hash='e80db433db641bb390ade991b81f98814a26c7de30e0da6f20e8abddf7a84538', extract_dir='') download_file(url,
The file has been downloaded and saved to: /home/export/personal/miguel/git_projects/bioMONAI/nbs/_data
Prepare Image Paths and Update Metadata
In the next cell, we will prepare the image paths for each channel and update the metadata CSV file with these paths. This step is crucial for organizing the dataset and ensuring that each image is correctly associated with its corresponding metadata.
- We will read the metadata CSV file and extract the site IDs.
- For each site ID, we will generate the paths for the six channels of images.
- These paths will be stored in a dictionary and added as new columns to the metadata CSV file.
- A new CSV file will be created to avoid overwriting the original metadata file.
- You can modify the
data_folder
andcsv_file
variables to point to a different dataset or metadata file.- If your dataset contains a different number of channels, adjust the range in the
channel_list
generation accordingly.- Ensure that the directory structure and file naming conventions match those expected by the code.
= '../_data/rxrx1_subset_monai/'
data_folder = data_folder + 'metadata.csv'
csv_file
import pandas as pd
= pd.read_csv(csv_file)
df
# Extract image paths for all channels from csv file and create a dictionary to store them
= [],[],[],[],[],[]
ch1, ch2, ch3, ch4, ch5,ch6 for sid in df['site_id']:
= sid.split('_')
site_id = os.path.join('images', site_id[0], f'Plate{site_id[1]}', f'{site_id[2]}_s{site_id[3]}_w')
base_image_path = [f'{base_image_path}{i}.png' for i in range(1,7)]
channel_list 0])
ch1.append(channel_list[1])
ch2.append(channel_list[2])
ch3.append(channel_list[3])
ch4.append(channel_list[4])
ch5.append(channel_list[5])
ch6.append(channel_list[= {'channel 1': ch1, 'channel 2': ch2, 'channel 3': ch3, 'channel 4': ch4, 'channel 5': ch5, 'channel 6': ch6}
image_paths
# Let's create a new csv file to avoid overwriting the original one, and add the image paths to it in new columns
= data_folder + 'metadata_updated.csv'
new_csv_file add_columns_to_csv(csv_file, image_paths, new_csv_file)
Columns ['channel 1', 'channel 2', 'channel 3', 'channel 4', 'channel 5', 'channel 6'] added successfully. Updated file saved to '../_data/rxrx1_subset_monai/metadata_updated.csv'
Split Dataset into Train, Validation, and Test Sets
In the next cell, we will split the updated metadata CSV file into training, validation, and test sets. This step is essential for training and evaluating our classification model. The split_dataframe
function is used to perform the split based on the specified fractions.
- The
train_fraction
parameter determines the proportion of the dataset to be used for training. - The
valid_fraction
parameter determines the proportion of the dataset to be used for validation. - The
split_column
parameter specifies the column to be used for splitting the dataset. Using this parameter is alternative to ‘train_fraction’ and ‘valid_fraction’ parameters. - The
add_is_valid
parameter adds a column to indicate whether a sample belongs to the validation set. - The
train_path
,test_path
, andvalid_path
parameters specify the file paths for the resulting CSV files. - The
data_save_path
parameter specifies the directory where the CSV files will be saved.
- You can adjust the
train_fraction
andvalid_fraction
parameters to change the proportions of the splits.- Modify the
split_column
parameter if you want to use a different column for splitting.- Ensure that the
data_save_path
directory exists and has write permissions.
# Split data based on 'split_column' values in csv file
split_dataframe(new_csv_file, ='dataset',
split_column=True,
add_is_valid="train.csv",
train_path="test.csv",
test_path="valid.csv",
valid_path=data_folder
data_save_path
)
# # Split data based on 'train_fraction' and 'valid_fraction' values in csv file
# split_dataframe(new_csv_file,
# train_fraction=0.7,
# valid_fraction=0.05,
# add_is_valid=True,
# train_path="train.csv",
# test_path="test.csv",
# valid_path="valid.csv",
# data_save_path=data_folder
# )
Train set saved to '../_data/rxrx1_subset_monai/train.csv'.
Test set saved to '../_data/rxrx1_subset_monai/test.csv'.
'is_valid' column added to '../_data/rxrx1_subset_monai/train.csv' for validation samples.
Data Augmentation and DataLoader Preparation
In the next cell, we will define the data augmentation techniques and prepare the data loaders for training and validation. Data augmentation is crucial for improving the generalization of our model by artificially increasing the diversity of the training dataset. We will use a combination of intensity scaling, random cropping, rotation, and flipping transformations.
- The
ScaleIntensityPercentiles
transformation scales the intensity values of the images based on the specified percentiles. - The
RandomResizedCrop
transformation randomly crops the images to the specified size with a random scale. - The
RandRot90
transformation randomly rotates the images by 90 degrees with the specified probability. - The
RandFlip
transformation randomly flips the images horizontally or vertically with the specified probability. - The
BioDataLoaders.class_from_csv
function is used to create the data loaders from the CSV file containing the image paths and labels.
- You can adjust the
bs
variable to change the batch size.- Modify the parameters of the transformations to experiment with different augmentation techniques.
- Ensure that the
fn_col
andlabel_col
parameters match the columns in your CSV file.- Set
show_summary
toTrue
to display a summary of the data loaders.
from fastai.vision.all import RandomResizedCrop
= 8
batch_size
= [ScaleIntensityPercentiles(1,99), RandomResizedCrop(512,min_scale=0.9, max_scale=1.1), RandRot90(prob=.75), RandFlip(prob=0.5)]
itemTfms = []
batchTfms
= {
data_ops 'fn_col': [12,13,14,15,16,17],
'label_col': 3,
'valid_col': -1,
'seed': 42,
'bs': batch_size,
'img_cls': BioImageMulti,
'item_tfms': itemTfms,
'batch_tfms': batchTfms,
}
= BioDataLoaders.class_from_csv(
data
data_folder,'train.csv',
=False,
show_summary**data_ops,
)
# print length of training and validation datasets
print('train images:', len(data.train_ds.items), '\nvalidation images:', len(data.valid_ds.items))
train images: 875
validation images: 125
Visualize Data Batch
In the next cell, we will visualize a batch of images from the training dataset. This step is essential for verifying that the data augmentation techniques are applied correctly and that the images are loaded as expected. The show_batch
method of the BioDataLoaders
class is used to display a batch of images with their corresponding labels.
- The
max_slices
parameter specifies the maximum number of slices to display for each image. - The
layout
parameter determines the layout of the displayed images. The ‘multirow’ layout arranges the images in multiple rows.
- You can adjust the
max_slices
parameter to display more or fewer slices per image.- Modify the
layout
parameter to experiment with different layouts, such as ‘single’ or ‘grid’.- Ensure that the data loaders are correctly defined and contain the expected images and labels.
=6, layout='multirow') data.show_batch(max_slices
Visualize a Specific Image
In the next cell, we will visualize a specific image from the dataset using its index. This step is useful for inspecting individual images and verifying their quality and labels. The do_item
method of the BioDataLoaders
class is used to retrieve the image and its label, and the show
method is used to display the image.
= data.do_item(100)
a 0].show(max_slices=6, layout='multirow'); a[
Define and Train the Model
In the next cell, we will define and train a DenseNet169 model for our multispectral classification task. The model is initialized with the following parameters: - spatial_dims=2
: Specifies that the input images are 2D. - in_channels=6
: Specifies the number of input channels, which corresponds to the six multispectral channels. - out_channels=data.c
: Specifies the number of output channels, which corresponds to the number of classes in our dataset. - pretrained=True
: Initializes the model with pretrained weights.
We will also define the metrics to evaluate the model’s performance during training. The RocAuc
and accuracy
metrics are used to measure the model’s performance.
The fastTrainer
class is used to train the model with the specified data loaders and metrics. The fine_tune
method is called to fine-tune the model for a specified number of epochs, with an initial phase of freezing the pretrained layers.
- You can experiment with different model architectures by replacing
DenseNet169
with other models from themonai.networks.nets
module.- Adjust the
in_channels
parameter if your dataset contains a different number of channels.- Modify the
out_channels
parameter if your dataset has a different number of classes.- Experiment with different metrics by adding or removing metrics from the
metrics
list.- Adjust the number of epochs and the
freeze_epochs
parameter to control the training process.
from monai.networks.nets import DenseNet169
= DenseNet169(spatial_dims=2, in_channels=6, out_channels=data.c, pretrained=True) model
from fastai.vision.all import RocAuc, accuracy
= [RocAuc(), accuracy]
metrics
= fastTrainer(data, model, metrics=metrics, show_summary=False) trainer
4, freeze_epochs=2) trainer.fine_tune(
epoch | train_loss | valid_loss | roc_auc_score | accuracy | time |
---|---|---|---|---|---|
0 | 0.505676 | 1.161192 | 0.967541 | 0.792000 | 00:46 |
1 | 0.572242 | 0.647058 | 0.961783 | 0.776000 | 00:47 |
epoch | train_loss | valid_loss | roc_auc_score | accuracy | time |
---|---|---|---|---|---|
0 | 0.283460 | 0.776095 | 0.982874 | 0.784000 | 00:47 |
1 | 0.336061 | 0.460775 | 0.981883 | 0.840000 | 00:47 |
2 | 0.200890 | 0.097510 | 0.999682 | 0.976000 | 00:49 |
3 | 0.107568 | 0.078875 | 0.999664 | 0.968000 | 00:39 |
Save the Trained Model
In the next cell, we will save the trained model to a file. This step is crucial for preserving the model’s state after training, allowing us to load and use the model later without retraining. The save
method of the fastTrainer
class is used to save the model to the specified file path.
- The
save
method takes the file name as an argument and saves the model’s state dictionary to a file with the.pth
extension. - The saved model can be loaded later using the
load
method of thefastTrainer
class.
- You can change the file name to save the model with a different name.
- Ensure that the directory where the model is saved exists and has write permissions.
- Consider saving multiple versions of the model during training to keep track of different checkpoints.
'multispectral-classification-model') trainer.save(
Path('../_data/rxrx1_subset_monai/models/multispectral-classification-model.pth')
Evaluate the Model on Test Data
In the next cell, we will evaluate the trained model on the test dataset. This step is crucial for assessing the model’s performance on unseen data and understanding its generalization capabilities. The BioDataLoaders.class_from_csv
function is used to create the data loader for the test dataset, and the evaluate_classification_model
function is used to compute the evaluation metrics.
- The
fn_col
parameter specifies the columns containing the file paths for the multispectral channels. - The
label_col
parameter specifies the column containing the labels. - The
valid_pct
parameter is set to 0, indicating that no validation split is needed for the test dataset. - The
item_tfms
parameter applies theScaleIntensityPercentiles
transformation to the test images. - The
batch_tfms
parameter applies any batch-level transformations (if defined). - The
bs
parameter specifies the batch size for loading the test data. - The
evaluate_classification_model
function takes the trained model, test data loader, and evaluation metrics as inputs and returns the computed scores.
- You can adjust the
bs
variable to change the batch size for loading the test data.- Modify the
fn_col
andlabel_col
parameters to match the columns in your test CSV file.- Add or remove transformations in the
item_tfms
andbatch_tfms
lists to experiment with different preprocessing techniques.- Set
show_graph
toTrue
to visualize the evaluation results.
= BioDataLoaders.class_from_csv(
test_data
data_folder,'test.csv',
=[12,13,14,15,16,17],
fn_col=3,
label_col=0,
valid_pct=42,
seed=BioImageMulti,
img_cls=[ScaleIntensityPercentiles(1,99)],
item_tfms=batchTfms,
batch_tfms=False,
show_summary= 50,
bs )
= evaluate_classification_model(trainer, test_data, metrics=accuracy, show_graph=False) scores
precision recall f1-score support
HEPG2 0.89 0.94 0.91 50
HUVEC 0.73 0.96 0.83 50
RPE 0.74 0.98 0.84 50
U2OS 1.00 0.30 0.46 50
accuracy 0.80 200
macro avg 0.84 0.79 0.76 200
weighted avg 0.84 0.80 0.76 200
Most Confused Classes:
[('U2OS', 'HUVEC', 16), ('U2OS', 'RPE', 13), ('U2OS', 'HEPG2', 6), ('HEPG2', 'RPE', 2), ('HUVEC', 'RPE', 2), ('HEPG2', 'HUVEC', 1), ('RPE', 'HUVEC', 1)]
Value | |
---|---|
CrossEntropyLossFlat | |
Mean | 0.968318 |
Median | 0.795801 |
Standard Deviation | 0.308431 |
Min | 0.743671 |
Max | 1.740729 |
Q1 | 0.749687 |
Q3 | 1.085939 |
Value | |
---|---|
accuracy | |
Mean | 0.795000 |
Median | 1.000000 |
Standard Deviation | 0.403702 |
Min | 0.000000 |
Max | 1.000000 |
Q1 | 1.000000 |
Q3 | 1.000000 |
Load the Model
In this step, we will load the previously trained model using the load
method of the visionTrainer
class. In this example, we will:
- Create a trainer instance and load the previously saved model.
- Fine tune the model a several epochs more.
- Evaluate the model with test data again.
= DenseNet169(spatial_dims=2, in_channels=6, out_channels=data.c, pretrained=True)
model
= [RocAuc(), accuracy]
metrics
= fastTrainer(data, model, metrics=metrics, show_summary=True, find_lr=True)
trainer2
# Load saved model
'multispectral-classification-model')
trainer2.load(
# Train several additional epochs
2, lr_max=6e-5)
trainer2.fit_one_cycle(
# Evaluate the model on the test dataset
=False); evaluate_classification_model(trainer2, test_data, show_graph
DenseNet169 (Input shape: 8 x 6 x 512 x 512)
============================================================================
Layer (type) Output Shape Param # Trainable
============================================================================
8 x 64 x 256 x 256
Conv2d 18816 True
BatchNorm2d 128 True
ReLU
____________________________________________________________________________
8 x 64 x 128 x 128
MaxPool2d
BatchNorm2d 128 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 8192 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 192 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 12288 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 256 True
ReLU
Conv2d 16384 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 320 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 20480 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 384 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 24576 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 448 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 28672 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 128 x 128
Conv2d 36864 True
BatchNorm2d 512 True
ReLU
____________________________________________________________________________
8 x 128 x 128 x 128
Conv2d 32768 True
____________________________________________________________________________
8 x 128 x 64 x 64
AvgPool2d
BatchNorm2d 256 True
ReLU
Conv2d 16384 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 320 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 20480 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 384 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 24576 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 448 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 28672 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 512 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 32768 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 576 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 36864 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 640 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 40960 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 704 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 45056 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 768 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 49152 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 832 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 53248 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 896 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 57344 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 960 True
ReLU
____________________________________________________________________________
8 x 128 x 64 x 64
Conv2d 61440 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 64 x 64
Conv2d 36864 True
BatchNorm2d 1024 True
ReLU
____________________________________________________________________________
8 x 256 x 64 x 64
Conv2d 131072 True
____________________________________________________________________________
8 x 256 x 32 x 32
AvgPool2d
BatchNorm2d 512 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 32768 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 576 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 36864 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 640 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 40960 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 704 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 45056 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 768 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 49152 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 832 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 53248 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 896 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 57344 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 960 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 61440 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1024 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 65536 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1088 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 69632 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1152 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 73728 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1216 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 77824 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1280 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 81920 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1344 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 86016 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1408 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 90112 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1472 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 94208 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1536 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 98304 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1600 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 102400 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1664 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 106496 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1728 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 110592 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1792 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 114688 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1856 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 118784 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1920 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 122880 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 1984 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 126976 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2048 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 131072 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2112 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 135168 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2176 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 139264 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2240 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 143360 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2304 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 147456 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2368 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 151552 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2432 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 155648 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2496 True
ReLU
____________________________________________________________________________
8 x 128 x 32 x 32
Conv2d 159744 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 32 x 32
Conv2d 36864 True
BatchNorm2d 2560 True
ReLU
____________________________________________________________________________
8 x 640 x 32 x 32
Conv2d 819200 True
____________________________________________________________________________
8 x 640 x 16 x 16
AvgPool2d
BatchNorm2d 1280 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 81920 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1344 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 86016 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1408 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 90112 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1472 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 94208 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1536 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 98304 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1600 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 102400 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1664 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 106496 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1728 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 110592 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1792 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 114688 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1856 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 118784 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1920 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 122880 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 1984 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 126976 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2048 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 131072 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2112 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 135168 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2176 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 139264 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2240 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 143360 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2304 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 147456 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2368 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 151552 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2432 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 155648 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2496 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 159744 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2560 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 163840 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2624 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 167936 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2688 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 172032 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2752 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 176128 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2816 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 180224 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2880 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 184320 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 2944 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 188416 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3008 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 192512 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3072 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 196608 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3136 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 200704 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3200 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 204800 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3264 True
ReLU
____________________________________________________________________________
8 x 128 x 16 x 16
Conv2d 208896 True
BatchNorm2d 256 True
ReLU
____________________________________________________________________________
8 x 32 x 16 x 16
Conv2d 36864 True
BatchNorm2d 3328 True
ReLU
____________________________________________________________________________
8 x 1664 x 1 x 1
AdaptiveAvgPool2d
____________________________________________________________________________
8 x 1664
Flatten
____________________________________________________________________________
8 x 4
Linear 6660 True
____________________________________________________________________________
Total params: 12,500,548
Total trainable params: 12,500,548
Total non-trainable params: 0
Optimizer used: <function Adam>
Loss function: FlattenedLoss of CrossEntropyLoss()
Callbacks:
- TrainEvalCallback
- CastToTensor
- Recorder
- ProgressCallback
- ShowGraphCallback
Inferred learning rate: 8e-05
epoch | train_loss | valid_loss | roc_auc_score | accuracy | time |
---|---|---|---|---|---|
0 | 0.115464 | 0.049460 | 1.000000 | 0.968000 | 00:27 |
1 | 0.082040 | 0.050287 | 1.000000 | 1.000000 | 00:27 |
precision recall f1-score support
HEPG2 0.80 0.90 0.85 50
HUVEC 0.82 0.90 0.86 50
RPE 0.60 0.98 0.74 50
U2OS 1.00 0.14 0.25 50
accuracy 0.73 200
macro avg 0.80 0.73 0.67 200
weighted avg 0.80 0.73 0.67 200
Most Confused Classes:
[('U2OS', 'RPE', 23), ('U2OS', 'HEPG2', 11), ('U2OS', 'HUVEC', 9), ('HEPG2', 'RPE', 5), ('HUVEC', 'RPE', 5), ('RPE', 'HUVEC', 1)]
Value | |
---|---|
CrossEntropyLossFlat | |
Mean | 1.007188 |
Median | 0.801270 |
Standard Deviation | 0.341419 |
Min | 0.743669 |
Max | 1.739640 |
Q1 | 0.747051 |
Q3 | 1.276401 |