Skip to content

Commit

Permalink
Don't assign weights to changed topos.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrpi committed Oct 11, 2022
1 parent 8c477fa commit 780867b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/analyzers/executables/cloudplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ def post_status_closure(status):
if error_bars:
means = predict[:,j,:].mean(axis=1)
stds = predict[:,j,:].std(axis=1)
plt.errorbar(inputs, means, stds, uplimes=False, lolimes=False, capsize=3, fmt="none")
plt.scatter(inputs, means)
plt.errorbar(outputs[:,j], means, stds, uplims=False, lolims=False, capsize=3, fmt="none")
plt.scatter(outputs[:,j], means)
ll = np.amin(means - stds)
ul = np.amax(means + stds)
else:
for i in range(n_rows):
known = outputs[i,j].repeat(n_samples)
Expand Down
8 changes: 5 additions & 3 deletions src/common/mko/mko.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ def from_dict(data: dict) -> 'MKO':
def parameterize_model(self):
if self._compiled and self._has_weights:
weights = encodings.b64decode_datatype(self._weights)
for i, layer in enumerate(self._model.layers):
layer.set_weights(weights[i])
self._parameterized = True
n_layers = len(self._model.layers)
if len(weights) == n_layers:
for i, layer in enumerate(self._model.layers):
layer.set_weights(weights[i])
self._parameterized = True

@staticmethod
def from_json(j_str: str) -> 'MKO':
Expand Down
4 changes: 3 additions & 1 deletion src/common/ml/model_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def compile_model(model, hypers, optimizer_state=None):
_ = model.optimizer.iterations
model.optimizer._create_hypers()
model.optimizer._create_slots(model.trainable_weights)
model.optimizer.set_weights(optimizer_state)
n_weights = len(model.optimizer.get_weights())
if n_weights == len(optimizer_state):
model.optimizer.set_weights(optimizer_state)
else:
K.set_value(model.optimizer.learning_rate, hypers['learning_rate'])
return model
Expand Down

0 comments on commit 780867b

Please sign in to comment.