<jupyter_start><jupyter_text>[ CAE - RBF OCSVM ]202106111432 210608 Loss-1  - Center orthogonal  ||center|| == 1 추가  System Configuration<jupyter_code>import os
import pathlib
import sys

default_dir_path = str(pathlib.Path(os.getcwd()).parent.absolute())

sys.path.append(default_dir_path)

from properties import *<jupyter_output>Global seed set to 777
[2021-06-11 14:32:00,490][INFO][properties.py:22] Complete to apply the random seed, RANDOM_SEED : 777<jupyter_text>---<jupyter_code>from pathlib import Path
from config.factory import HyperparameterFactory
from dataset.factory import DataModuleFactory
from domain.metadata import ModelMetadata
from logger import logger
from model.factory import ModelFactory
from trainer.base import TrainerBase
model_name = "conv_cae"
data_name = "mnist"
stage = "fit"
tqdm_env = "notebook"
model_metadata = ModelMetadata(model_name=model_name, information=None)
# Arguments controller
hyperparameter_factory = HyperparameterFactory.create(data_name=data_name, model_name=model_name)
datamodule_params = hyperparameter_factory.datamodule_params
trainer_params = hyperparameter_factory.trainer_params
model_params = hyperparameter_factory.model_params
# DataModule controller
datamodule = DataModuleFactory.create(data_name=data_name, model_name=model_name)
datamodule = datamodule(**datamodule_params)

datamodule.prepare_data()
datamodule.setup(stage=stage)

datamodule.train_dataloader()

train_loader = datamodule.train_dataloader()
val_loader = datamodule.val_dataloader()
test_loader = datamodule.test_dataloader()
# train_id_dataloader = datamodule.train_id_dataloader()
# train_ood_dataloader = datamodule.train_ood_dataloader()
# val_id_dataloader = datamodule.val_id_dataloader()
# val_ood_dataloader = datamodule.val_ood_dataloader()
# test_dataloader = datamodule.test_dataloader()
# del model_params.lr
# model_params
import matplotlib.pyplot as plt

data = datamodule.train_id_dataset[5]

print(data[1])
plt.imshow(data[0].numpy().squeeze())
plt.show()
# Model controller
model = ModelFactory.create(model_name=model_name, model_metadata=model_metadata, model_params=model_params)
# model.latent_dir_path = os.path.join(trainer.model_metadata.model_file_metadata.model_current_version_dir_path, "latent")
# Path(model.latent_dir_path).mkdir(parents=True, exist_ok=True)

# model.checkpoints_period = 5


# model.train_id_dataloader = train_id_dataloader
# model.train_ood_dataloader = train_ood_dataloader
# model.val_id_dataloader = val_id_dataloader
# model.val_ood_dataloader = val_ood_dataloader
# model.test_dataloader = test_dataloader
# Trainer controller
trainer = TrainerBase(model_metadata=model_metadata, model=model, **trainer_params)
trainer.arg
# # Find the optimal learning rate
# if trainer.is_auto_lr_find:
#     trainer.lr_find(model=model, train_loader=train_loader, val_loader=val_loader)
# metrics on_epoch
# Training & Validation
if stage == "fit":
    trainer.fit(model=model, datamodule=datamodule)
#     trainer.fit(model=model, train_dataloader=train_loader, val_dataloaders=val_loader)
#     trainer.fit(model=model)<jupyter_output>LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1,2,3,4,5,6,7]
[2021-06-11 14:32:07,757][DEBUG][metadata.py:144] Create current version 202106111432, Path : /workspace/Project/2021_AI_security/model/results/conv_cae/202106111432

   | Name                 | Type       | Params
-----------------------------------------------------
0  | train_acc            | Accuracy   | 0     
1  | train_precision      | Precision  | 0     
2  | train_recall         | Recall     | 0     
3  | train_f1             | F1         | 0     
4  | train_auc            | AUROC      | 0     
5  | validation_acc       | Accuracy   | 0     
6  | validation_precision | Precision  | 0     
7  | validation_recall    | Recall     | 0     
8  | validation_f1        | F1         | 0     
9  | test_acc             | Accuracy   | 0     
10 | test_precision       | Precision  | 0     
11 | test_recall          | Recall     | 0     
12 | test_f1              | F1         | 0     
13 | model_loss_function  | CAELoss    | 160   
14 [...]<jupyter_text>Reproduction<jupyter_code># model.save_best_model_output(datamodule=datamodule)
# print(model.model_file_metadata.current_version_checkpoints_dir_path(is_absolute_path=True))
best_model = model.load_checkpoint(epoch=54, version="202106040450")
best_model<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10303442028985507, 'fraction_numerical': 0.036684782608695655, 'mean_word_length': 4.5420326223337515, 'pattern_counts': {'":': 1, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '301831', 'license': 'Apache-2.0', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1536, 'n_words': 258, 'path': 'notebook/conv_cae-rbf_ocsvm-with_fc_learning-hparam1-id-ood-v4.ipynb', 'repo_name': 'ByeongGil-Jung/2021-AI-Security', 'size': '4416'}