-
Notifications
You must be signed in to change notification settings - Fork 64
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
NNsPOD #221
NNsPOD #221
Conversation
be97435
to
37cf70a
Compare
820cdd7
to
dea1126
Compare
ezyrb/ann.py
Outdated
@@ -122,11 +122,10 @@ def fit(self, points, values): | |||
""" | |||
|
|||
self._build_model(points, values) | |||
self.optimizer = torch.optim.Adam(self.model.parameters()) | |||
self.optimizer = torch.optim.Adam(self.model.parameters(), lr = 0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the possibility to pass the optimizer (Adam by default) and the learning_rate (0.001 by default)?
ezyrb/ann.py
Outdated
@@ -143,7 +142,7 @@ def fit(self, points, values): | |||
elif isinstance(criteria, float): # stop criteria is float | |||
if loss.item() < criteria: | |||
flag = False | |||
|
|||
print(loss.item()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have something more customizable? Like decide the print frequency (frequency_print
should be an optional argument in the constructor) like in this snippet
if epoch % frequency_print == 0 or epoch == 1:
print('[epoch {:05d}] {:.6e}'.format(self.trained_epoch, loss.item()))
ezyrb/ann.py
Outdated
def predict_tensor(self, new_point): | ||
|
||
return self.model(new_point) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a method is just a type specification of the predict
method. Please avoid that, and instead check the type inside predict
and use conversion only if the input is NumPy
ezyrb/ann.py
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many blank lines
ezyrb/ann.py
Outdated
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many blank lines
ezyrb/nnspod.py
Outdated
|
||
def reshape2dto1d(self, x, y): | ||
""" | ||
reshapes graphable data into data that can go through the Neural Net |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with "graphable" data?
ezyrb/nnspod.py
Outdated
def reshape2dto1d(self, x, y): | ||
""" | ||
reshapes graphable data into data that can go through the Neural Net | ||
:param array x: x value of data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be numpy.array
ezyrb/nnspod.py
Outdated
return snapshots.reshape(int(np.sqrt(len(snapshots))), int(np.sqrt(len(snapshots)))) | ||
|
||
|
||
def train_InterpNet1d(self,ref_data, interp_layers, interp_function, interp_stop_training, interp_loss, retrain = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no capital in method names
ezyrb/nnspod.py
Outdated
|
||
|
||
|
||
def train_InterpNet2d(self,ref_data, interp_layers, interp_function, interp_stop_training, interp_loss, retrain = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge function for 1D e 2D. Keep always one general function, instead of specifying several methods for different dimensions
In the NNsPOD class the |
0f054a3
to
1171901
Compare
@@ -99,7 +99,7 @@ def _build_model(self, points, values): | |||
layers_torch.append(nn.Linear(layers[-2], layers[-1])) | |||
self.model = nn.Sequential(*layers_torch) | |||
|
|||
def fit(self, points, values): | |||
def fit(self, points, values, optimizer = torch.optim.Adam, learning_rate = 0.001, frequency_print = 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimizer
and learning_rate
should be constructor arguments
Merged in #232 |
implementation of NNsPOD for ezyrb