added example and verified

This commit is contained in:
William Falcon 2019-03-31 16:34:13 -04:00
parent 9d56b1744f
commit 9ff6108af1
2 changed files with 11 additions and 16 deletions

View File

@ -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

View File

@ -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