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 -2 -4 7 -1 -1 -4 -3 -2 -2 -1 -2 -4
S 1 -1 1 0 -1 0 0 0 -1 -2 -2 0 -1 -2 -1 4 1 -3 -2 -2 0 0 0 -4
T 0 -1 0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1 1 5 -2 -2 0 -1 -1 0 -4
W -3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1 1 -4 -3 -2 11 2 -3 -4 -3 -2 -4
Y -2 -2 -2 -3 -2 -1 -2 -3 2 -1 -1 -2 -1 3 -3 -2 -2 2 7 -1 -3 -2 -1 -4
V 0 -3 -3 -3 -1 -2 -2 -3 -3 3 1 -2 1 -1 -2 -2 0 -3 -1 4 -3 -2 -1 -4
B -2 -1 3 4 -3 0 1 -1 0 -3 -4 0 -3 -3 -2 0 -1 -4 -3 -3 4 1 -1 -4
Z -1 0 0 1 -3 3 4 -2 0 -3 -3 1 -1 -3 -1 0 -1 -3 -2 -2 1 4 -1 -4
X 0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 0 0 -2 -1 -1 -1 -1 -1 -4
* -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 1
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -172,16 +172,16 @@ class TrainModel: ...@@ -172,16 +172,16 @@ class TrainModel:
def _log_printing(self, epoch, loss_train, acc_train, time, loss_val=None, acc_val=None): def _log_printing(self, epoch, loss_train, acc_train, time, loss_val=None, acc_val=None):
log = f' Epoch: {epoch} '\ log = f' Epoch: {epoch} '\
f' Lr: {self.lr:.7f} '\ f' Lr: {self.lr} '\
f' Loss: Train = [{loss_train:.4f}]' f' Loss: Train = [{loss_train:.4f}]'
if loss_val: if loss_val:
log += f' - Val = [{loss_val:.4f}] ' log += f' - Val = [{loss_val:.4f}] '
log += f' Accuracy: Train = [{acc_train:.2f}%]' log += f' Accuracy: Train = [{acc_train:.4f}%]'
if acc_val: if acc_val:
log += f' - Val = [{acc_val:.2f}%] ' log += f' - Val = [{acc_val:.4f}%] '
log += f' Time one epoch (s): {(time):.4f} ' log += f' Time one epoch (s): {(time):.4f} '
......
import argparse import argparse
import numpy as np
import torch import torch
import torch.nn as nn
from typing import Dict
from typing import Dict
from model import get_model from model import get_model
from data.preprocessing import MyDataset, PreprocessData from data.preprocessing import MyDataset, PreprocessData
from trainer.trainer_profilesm import TrainProfileESM from trainer.trainer_profilesm import TrainProfileESM
...@@ -56,9 +55,9 @@ class TrainingPipeline: ...@@ -56,9 +55,9 @@ class TrainingPipeline:
if not (self.base_dir/ fpath).exists() or not fpath.endswith(".csv"): if not (self.base_dir/ fpath).exists() or not fpath.endswith(".csv"):
raise Exception("file type incorrect or path doesn't exist") raise Exception("file type incorrect or path doesn't exist")
data, targets = PreprocessData(fpath).get_data() dataframe = PreprocessData(fpath).get_data()
dataset = MyDataset(data, targets) dataset = MyDataset(dataframe)
dataset.split_data(self.seed,val_set=validate) dataset.split_data(self.seed,val_set=validate)
dataset.plot_distribution() dataset.plot_distribution()
......
from collections import defaultdict import pandas as pd
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
from collections import defaultdict
def make_splits(targets, seed, val_set=True, stratify=True): def make_splits(targets, seed, val_set=True, stratify=True):
data_idx = np.arange(len(targets), dtype=int) data_idx = np.arange(len(targets))
train_idx, test_idx = train_test_split( train_idx, test_idx = train_test_split(
data_idx, test_size=0.2, random_state=seed, stratify=targets if stratify else None data_idx, test_size=0.2, random_state=seed, stratify=targets if stratify else None
) )
if not val_set: split_dict = defaultdict(pd.DataFrame)
return {'train': train_idx, split_dict['train'] = train_idx
'test' : test_idx} split_dict['test'] = test_idx
if val_set:
train_idx, val_idx = train_test_split( train_idx, val_idx = train_test_split(
train_idx, test_size=0.2, random_state=seed, stratify=targets[train_idx] if stratify else None train_idx, test_size=0.2, random_state=seed, stratify=targets[train_idx] if stratify else None
) )
return {'train': train_idx, split_dict['train'] = train_idx
'val' : val_idx, split_dict['val'] = val_idx
'test' : test_idx}
return split_dict
def make_plot_distribution(dataset_info, len_datasets, class2colors): def make_plot_distribution(dataset_info, len_datasets, class2colors):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment