Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
13 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
from model import BostonHousingModel | ||
import tensorflow as tf | ||
from model_zoo.trainer import BaseTrainer | ||
from tensorflow.python.keras.datasets import boston_housing | ||
from sklearn.preprocessing import StandardScaler | ||
from model_zoo.preprocess import standardize | ||
|
||
tf.flags.DEFINE_integer('epochs', 20, 'Max epochs') | ||
tf.flags.DEFINE_string('model_class', 'BostonHousingModel', 'Model class name') | ||
|
||
|
||
class Trainer(BaseTrainer): | ||
|
||
def __init__(self): | ||
BaseTrainer.__init__(self) | ||
self.model_class = BostonHousingModel | ||
|
||
def prepare_data(self): | ||
from tensorflow.python.keras.datasets import boston_housing | ||
(x_train, y_train), (x_eval, y_eval) = boston_housing.load_data() | ||
ss = StandardScaler() | ||
ss.fit(x_train) | ||
x_train, x_eval = ss.transform(x_train), ss.transform(x_eval) | ||
x_train, x_eval = standardize(x_train, x_eval) | ||
train_data, eval_data = (x_train, y_train), (x_eval, y_eval) | ||
return train_data, eval_data | ||
|
||
|
||
if __name__ == '__main__': | ||
Trainer().run() |