Merge pull request 'updated version to support proper saving when pretraining' (#11) from feat/fix_saving into develop
Reviewed-on: #11
This commit is contained in:
commit
8cf26dc72f
13
example.py
13
example.py
|
@ -1,21 +1,18 @@
|
||||||
data_path1 = "/root/training_data/vision-dataset/images_checkpoint.parquet"
|
|
||||||
data_path2 = "/root/training_data/vision-dataset/vec_images_dataset.parquet"
|
|
||||||
|
|
||||||
from aiia.model import AIIABase
|
from aiia.model import AIIABase
|
||||||
from aiia.model.config import AIIAConfig
|
from aiia.model import AIIAConfig
|
||||||
from aiia.pretrain import Pretrainer
|
from aiia.pretrain import Pretrainer
|
||||||
|
|
||||||
# Create your model
|
# Create your model
|
||||||
config = AIIAConfig(model_name="AIIA-Base-512x10k-small", num_hidden_layers=6, hidden_size=256)
|
config = AIIAConfig(model_name="AIIA-Base-512x20k")
|
||||||
model = AIIABase(config)
|
model = AIIABase(config)
|
||||||
|
|
||||||
# Initialize pretrainer with the model
|
# Initialize pretrainer with the model
|
||||||
pretrainer = Pretrainer(model, learning_rate=config.learning_rate, config=config)
|
pretrainer = Pretrainer(model, learning_rate=1e-4)
|
||||||
|
|
||||||
# List of dataset paths
|
# List of dataset paths
|
||||||
dataset_paths = [
|
dataset_paths = [
|
||||||
data_path1,
|
"/path/to/dataset1.parquet",
|
||||||
data_path2
|
"/path/to/dataset2.parquet"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Start training with multiple datasets
|
# Start training with multiple datasets
|
||||||
|
|
|
@ -7,14 +7,16 @@ line-length = 88
|
||||||
target-version = ['py37']
|
target-version = ['py37']
|
||||||
include = '\.pyi?$'
|
include = '\.pyi?$'
|
||||||
|
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "aiia"
|
name = "aiia"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "AIIA Deep Learning Model Implementation"
|
description = "AIIA Deep Learning Model Implementation"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [
|
authors = [
|
||||||
{ name="Falko Habel", email="falko.habel@gmx.de" }
|
{name = "Falko Habel", email = "falko.habel@gmx.de"}
|
||||||
]
|
]
|
||||||
|
license = {text = "CC BY-NC 4.0"}
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"torch>=2.5.0",
|
"torch>=2.5.0",
|
||||||
"numpy",
|
"numpy",
|
||||||
|
@ -25,6 +27,6 @@ dependencies = [
|
||||||
requires-python = ">=3.7"
|
requires-python = ">=3.7"
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: CC BY-NC 4.0 License",
|
||||||
"Operating System :: OS Independent"
|
"Operating System :: OS Independent"
|
||||||
]
|
]
|
|
@ -4,4 +4,4 @@ from .data.DataLoader import DataLoader
|
||||||
from .pretrain.pretrainer import Pretrainer, ProjectionHead
|
from .pretrain.pretrainer import Pretrainer, ProjectionHead
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.2"
|
||||||
|
|
|
@ -112,7 +112,7 @@ class Pretrainer:
|
||||||
|
|
||||||
return batch_loss
|
return batch_loss
|
||||||
|
|
||||||
def train(self, dataset_paths, column="image_bytes", num_epochs=3, batch_size=2, sample_size=10000):
|
def train(self, dataset_paths,output_path:str="AIIA", column="image_bytes", num_epochs=3, batch_size=2, sample_size=10000):
|
||||||
"""
|
"""
|
||||||
Train the model using multiple specified datasets.
|
Train the model using multiple specified datasets.
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class Pretrainer:
|
||||||
|
|
||||||
if val_loss < best_val_loss:
|
if val_loss < best_val_loss:
|
||||||
best_val_loss = val_loss
|
best_val_loss = val_loss
|
||||||
self.model.save("AIIA-base-512")
|
self.model.save(output_path)
|
||||||
print("Best model saved!")
|
print("Best model saved!")
|
||||||
|
|
||||||
self.save_losses('losses.csv')
|
self.save_losses('losses.csv')
|
||||||
|
|
Loading…
Reference in New Issue