diff --git a/train.php b/train.php index 423d558d..6270e40c 100644 --- a/train.php +++ b/train.php @@ -2,6 +2,7 @@ include __DIR__ . '/vendor/autoload.php'; +use Rubix\ML\Other\Loggers\Screen; use Rubix\ML\Datasets\Labeled; use Rubix\ML\PersistentModel; use Rubix\ML\Pipeline; @@ -18,14 +19,15 @@ use Rubix\ML\NeuralNet\ActivationFunctions\LeakyReLU; use Rubix\ML\NeuralNet\Optimizers\AdaMax; use Rubix\ML\Persisters\Filesystem; -use Rubix\ML\Other\Loggers\Screen; use Rubix\ML\Datasets\Unlabeled; use function Rubix\ML\array_transpose; ini_set('memory_limit', '-1'); -echo 'Loading data into memory ...' . PHP_EOL; +$logger = new Screen(); + +$logger->info('Loading data into memory'); $samples = $labels = []; @@ -60,9 +62,7 @@ new Filesystem('sentiment.model', true) ); -$estimator->setLogger(new Screen('sentiment')); - -echo 'Training ...' . PHP_EOL; +$estimator->setLogger($logger); $estimator->train($dataset); @@ -73,7 +73,7 @@ ->toCSV(['scores', 'losses']) ->write('progress.csv'); -echo 'Progress saved to progress.csv' . PHP_EOL; +$logger->info('Progress saved to progress.csv'); if (strtolower(trim(readline('Save this model? (y|[n]): '))) === 'y') { $estimator->save(); diff --git a/validate.php b/validate.php index 69ea2ef2..a9cbac97 100644 --- a/validate.php +++ b/validate.php @@ -2,6 +2,7 @@ include __DIR__ . '/vendor/autoload.php'; +use Rubix\ML\Other\Loggers\Screen; use Rubix\ML\Datasets\Labeled; use Rubix\ML\PersistentModel; use Rubix\ML\Persisters\Filesystem; @@ -11,7 +12,9 @@ ini_set('memory_limit', '-1'); -echo 'Loading data into memory ...' . PHP_EOL; +$logger = new Screen(); + +$logger->info('Loading data into memory'); $samples = $labels = []; @@ -26,7 +29,7 @@ $estimator = PersistentModel::load(new Filesystem('sentiment.model')); -echo 'Making predictions ...' . PHP_EOL; +$logger->info('Making predictions'); $predictions = $estimator->predict($dataset); @@ -41,4 +44,4 @@ $results->toJSON()->write('report.json'); -echo 'Report saved to report.json' . PHP_EOL; +$logger->info('Report saved to report.json'); \ No newline at end of file