added example and verified
This commit is contained in:
parent
9d56b1744f
commit
9ff6108af1
15
README.md
15
README.md
|
@ -51,8 +51,6 @@ To use lightning do 2 things:
|
|||
#### Define the trainer
|
||||
|
||||
```python
|
||||
# trainer.py
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -83,16 +81,14 @@ def main(hparams):
|
|||
exp.save()
|
||||
|
||||
# build model
|
||||
print('loading model...')
|
||||
model = ExampleModel(hparams)
|
||||
print('model built')
|
||||
|
||||
# callbacks
|
||||
early_stop = EarlyStopping(
|
||||
monitor=hparams.early_stop_metric,
|
||||
patience=hparams.early_stop_patience,
|
||||
monitor='val_acc',
|
||||
patience=3,
|
||||
mode='min',
|
||||
verbose=True,
|
||||
mode=hparams.early_stop_mode
|
||||
)
|
||||
|
||||
model_save_path = '{}/{}/{}'.format(hparams.model_save_path, exp.name, exp.version)
|
||||
|
@ -101,8 +97,8 @@ def main(hparams):
|
|||
save_function=None,
|
||||
save_best_only=True,
|
||||
verbose=True,
|
||||
monitor=hparams.model_save_monitor_value,
|
||||
mode=hparams.model_save_monitor_mode
|
||||
monitor='val_acc',
|
||||
mode='min'
|
||||
)
|
||||
|
||||
# configure trainer
|
||||
|
@ -129,6 +125,7 @@ if __name__ == '__main__':
|
|||
|
||||
# train model
|
||||
main(hyperparams)
|
||||
|
||||
```
|
||||
|
||||
#### Define the model
|
||||
|
|
|
@ -28,16 +28,14 @@ def main(hparams):
|
|||
exp.save()
|
||||
|
||||
# build model
|
||||
print('loading model...')
|
||||
model = ExampleModel(hparams)
|
||||
print('model built')
|
||||
|
||||
# callbacks
|
||||
early_stop = EarlyStopping(
|
||||
monitor=hparams.early_stop_metric,
|
||||
patience=hparams.early_stop_patience,
|
||||
monitor='val_acc',
|
||||
patience=3,
|
||||
mode='min',
|
||||
verbose=True,
|
||||
mode=hparams.early_stop_mode
|
||||
)
|
||||
|
||||
model_save_path = '{}/{}/{}'.format(hparams.model_save_path, exp.name, exp.version)
|
||||
|
@ -46,8 +44,8 @@ def main(hparams):
|
|||
save_function=None,
|
||||
save_best_only=True,
|
||||
verbose=True,
|
||||
monitor=hparams.model_save_monitor_value,
|
||||
mode=hparams.model_save_monitor_mode
|
||||
monitor='val_acc',
|
||||
mode='min'
|
||||
)
|
||||
|
||||
# configure trainer
|
||||
|
|
Loading…
Reference in New Issue