You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by wa...@apache.org on 2023/09/05 04:28:57 UTC
[singa] branch dev-postgresql updated: Add implementation for get and set states
This is an automated email from the ASF dual-hosted git repository.
wangwei pushed a commit to branch dev-postgresql
in repository https://gitbox.apache.org/repos/asf/singa.git
The following commit(s) were added to refs/heads/dev-postgresql by this push:
new 7f0152a7 Add implementation for get and set states
new af1634c8 Merge pull request #1080 from NLGithubWP/update_train_mlp_
7f0152a7 is described below
commit 7f0152a72e4b0b162e6867fa987f5954de6b1da8
Author: working <57...@users.noreply.github.com>
AuthorDate: Sat Sep 2 20:51:11 2023 +0800
Add implementation for get and set states
---
examples/model_selection_psql/ms_mlp/train_mlp.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/examples/model_selection_psql/ms_mlp/train_mlp.py b/examples/model_selection_psql/ms_mlp/train_mlp.py
index a3f1df8b..1956de9e 100644
--- a/examples/model_selection_psql/ms_mlp/train_mlp.py
+++ b/examples/model_selection_psql/ms_mlp/train_mlp.py
@@ -182,6 +182,18 @@ class MSSGD(MSOptimizer):
self.dam_value.copy_from(dam_value)
self.decay_value.copy_from(decay_value)
+ def get_states(self):
+ states = super().get_states()
+ if self.mom_value > 0:
+ states[
+ 'moments'] = self.moments # a dict for 1st order moments tensors
+ return states
+
+ def set_states(self, states):
+ super().set_states(states)
+ if 'moments' in states:
+ self.moments = states['moments']
+ self.mom_value = self.momentum(self.step_counter)
# Data augmentation
def augmentation(x, batch_size):