Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Train parameter #26

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ptychonn/_train/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def train(
out_dir: pathlib.Path | None,
epochs: int = 1,
batch_size: int = 32,
training_fraction: float = 0.8,
) -> typing.Tuple[lightning.Trainer, lightning.pytorch.loggers.CSVLogger | ListLogger]:
"""Train a PtychoNN model.

Expand All @@ -178,6 +179,8 @@ def train(
The maximum number of training epochs
batch_size
The size of one training batch.
training_fraction
The proprotion of X_train and Y_train that is used for training.
"""
if out_dir is not None:
checkpoint_callback = lightning.pytorch.callbacks.ModelCheckpoint(
Expand Down Expand Up @@ -210,6 +213,7 @@ def train(
X_train,
Y_train,
batch_size,
training_fraction=training_fraction,
)

trainer.fit(
Expand Down