Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
perceptualrobots committed Jan 13, 2024
1 parent 0213521 commit ce8cf98
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 207 deletions.
186 changes: 92 additions & 94 deletions nbs/02_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
" name = link.get_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.3}'\n",
" value = f'{value:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
"\n",
" if hasattr(self, 'gain'):\n",
Expand All @@ -277,7 +277,7 @@
" name = link.get_name()\n",
" value = self.gain\n",
" if isinstance(value, float):\n",
" value = f'{value:4.3}'\n",
" value = f'{value:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
"\n",
" \n",
Expand All @@ -292,7 +292,7 @@
" name = link.get_graph_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.3}'\n",
" value = f'{value:4.2f}'\n",
" labels[(self.get_graph_name(), name)] = value\n",
"\n",
" if hasattr(self, 'gain'):\n",
Expand All @@ -303,7 +303,7 @@
" name = link.get_name()\n",
" value = self.gain\n",
" if isinstance(value, float):\n",
" value = f'{value:4.3}'\n",
" value = f'{value:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
" \n",
" \n",
Expand Down Expand Up @@ -1151,9 +1151,9 @@
" if isinstance(self.weights[0], int):\n",
" weights = self.weights\n",
" else:\n",
" weights = [float(f'{float(wt):4.3}') for wt in self.weights]\n",
" weights = [float(f'{float(wt):4.2f}') for wt in self.weights]\n",
"\n",
" super().summary(f'weights {weights} smooth {self.smooth_factor:4.3}', extra=extra)\n",
" super().summary(f'weights {weights} smooth {self.smooth_factor:4.2f}', extra=extra)\n",
" \n",
" \n",
" def get_parameters_list(self):\n",
Expand All @@ -1172,19 +1172,19 @@
" def get_suffix(self):\n",
" return 'sm'\n",
"\n",
" def get_weights_labels(self, labels):\n",
" for i in range(len(self.weights)):\n",
" link = self.get_link(i)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.2f}:{self.smooth_factor:4.2f}'\n",
" if isinstance(value, int) and value != 0:\n",
" value = f'{value:4.2f}:{self.smooth_factor:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
" # def get_weights_labels(self, labels):\n",
" # for i in range(len(self.weights)):\n",
" # link = self.get_link(i)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_name()\n",
" # value = self.weights[i]\n",
" # if isinstance(value, float):\n",
" # value = f'{value:4.2f}:{self.smooth_factor:4.2f}'\n",
" # if isinstance(value, int) and value != 0:\n",
" # value = f'{value:4.2f}:{self.smooth_factor:4.2f}'\n",
" # labels[(self.get_name(), name)] = value\n",
"\n",
" @deprecated(reason=\"Used by DynamicArchitecture\")\n",
" def set_node_function(self, function_type, thislevel, targetlevel, targetprefix, \n",
Expand Down Expand Up @@ -1321,8 +1321,8 @@
" if isinstance(self.weights[0], int):\n",
" weights = self.weights\n",
" else:\n",
" weights = [float(f'{float(wt):4.3}') for wt in self.weights]\n",
" super().summary(f'weights {weights} range {self.range:4.3} slope {self.slope:4.3}', extra=extra)\n",
" weights = [float(f'{float(wt):4.2f}') for wt in self.weights]\n",
" super().summary(f'weights {weights} range {self.range:4.2f} slope {self.slope:4.2f}', extra=extra)\n",
" \n",
" \n",
" def get_parameters_list(self):\n",
Expand All @@ -1342,22 +1342,22 @@
" def get_suffix(self):\n",
" return 'sg'\n",
"\n",
" def get_weights_labels(self, labels):\n",
" for i in range(len(self.weights)):\n",
" link = self.get_link(i)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.2f}:{self.range:4.2f}-{self.slope:4.2f}'\n",
" if isinstance(value, int) and value != 0:\n",
" value = f'{value:4.2f}:{self.range:4.2f}-{self.slope:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
" # def get_weights_labels(self, labels):\n",
" # for i in range(len(self.weights)):\n",
" # link = self.get_link(i)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_name()\n",
" # value = self.weights[i]\n",
" # if isinstance(value, float):\n",
" # value = f'{value:4.2f}:{self.range:4.2f}-{self.slope:4.2f}'\n",
" # if isinstance(value, int) and value != 0:\n",
" # value = f'{value:4.2f}:{self.range:4.2f}-{self.slope:4.2f}'\n",
" # labels[(self.get_name(), name)] = value\n",
" \n",
" def get_weights_labels_funcdata(self, labels):\n",
" self.get_weights_labels(labels)\n",
" # def get_weights_labels_funcdata(self, labels):\n",
" # self.get_weights_labels(labels)\n",
" \n",
" def get_graph_name(self):\n",
" return f'{self.name}\\n{self.range:4.2f}-{self.slope:4.2f}' \n",
Expand Down Expand Up @@ -1422,8 +1422,8 @@
" return super().__call__(verbose)\n",
"\n",
" def summary(self, extra=False):\n",
" weights = [float(f'{float(wt):4.3}') for wt in self.weights]\n",
" super().summary(f'weights {weights} smooth {self.smooth_factor:4.3} range {self.range:4.3} slope {self.slope:4.3}', extra=extra)\n",
" weights = [float(f'{float(wt):4.2f}') for wt in self.weights]\n",
" super().summary(f'weights {weights} smooth {self.smooth_factor:4.2f} range {self.range:4.2f} slope {self.slope:4.2f}', extra=extra)\n",
" \n",
" \n",
" def get_parameters_list(self):\n",
Expand All @@ -1445,22 +1445,22 @@
" def get_suffix(self):\n",
" return 'sgm'\n",
"\n",
" def get_weights_labels(self, labels):\n",
" for i in range(len(self.weights)):\n",
" link = self.get_link(i)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.2f}:{self.smooth_factor:4.2f}-{self.range:4.2f}-{self.slope:4.2f}'\n",
" if isinstance(value, int) and value != 0:\n",
" value = f'{value:4.2f}:{self.smooth_factor:4.2f}-{self.range:4.2f}-{self.slope:4.2f}-{self.smooth_factor:4.2f}'\n",
" labels[(self.get_name(), name)] = value\n",
" # def get_weights_labels(self, labels):\n",
" # for i in range(len(self.weights)):\n",
" # link = self.get_link(i)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_name()\n",
" # value = self.weights[i]\n",
" # if isinstance(value, float):\n",
" # value = f'{value:4.2f}:{self.smooth_factor:4.2f}-{self.range:4.2f}-{self.slope:4.2f}'\n",
" # if isinstance(value, int) and value != 0:\n",
" # value = f'{value:4.2f}:{self.smooth_factor:4.2f}-{self.range:4.2f}-{self.slope:4.2f}-{self.smooth_factor:4.2f}'\n",
" # labels[(self.get_name(), name)] = value\n",
"\n",
" def get_weights_labels_funcdata(self, labels):\n",
" self.get_weights_labels(labels)\n",
" # def get_weights_labels_funcdata(self, labels):\n",
" # self.get_weights_labels(labels)\n",
"\n",
" \n",
" def get_graph_name(self):\n",
Expand Down Expand Up @@ -1519,17 +1519,17 @@
" def get_suffix(self):\n",
" return 'dv'\n",
"\n",
" def get_weights_labels(self, labels):\n",
" link = self.get_link(0)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_name()\n",
" value = f'{self.history}'\n",
" labels[(self.get_name(), name)] = value\n",
" # def get_weights_labels(self, labels):\n",
" # link = self.get_link(0)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_name()\n",
" # value = f'{self.history}'\n",
" # labels[(self.get_name(), name)] = value\n",
"\n",
" def get_weights_labels_funcdata(self, labels):\n",
" self.get_weights_labels(labels)\n",
" # def get_weights_labels_funcdata(self, labels):\n",
" # self.get_weights_labels(labels)\n",
" \n",
" def get_graph_name(self):\n",
" return f'{self.name}\\n{self.history_length:4.2f}' \n",
Expand Down Expand Up @@ -1600,7 +1600,7 @@
" return super().__call__(verbose)\n",
"\n",
" def summary(self, extra=False):\n",
" weights = [float(f'{float(wt):4.3}') for wt in self.weights]\n",
" weights = [float(f'{float(wt):4.2f}') for wt in self.weights]\n",
" super().summary(f'weights {weights} history_length {self.history_length}', extra=extra)\n",
" \n",
" \n",
Expand All @@ -1621,37 +1621,35 @@
" def get_suffix(self):\n",
" return 'dvws'\n",
"\n",
" def get_weights_labels(self, labels):\n",
" for i in range(len(self.weights)):\n",
" link = self.get_link(i)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.2f}:{self.history_length}'\n",
" if isinstance(value, int) and value != 0:\n",
" value = f'{value:4.2f}:{self.history_length}'\n",
" labels[(self.get_name(), name)] = value\n",
" # def get_weights_labels(self, labels):\n",
" # for i in range(len(self.weights)):\n",
" # link = self.get_link(i)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_name()\n",
" # value = self.weights[i]\n",
" # if isinstance(value, float):\n",
" # value = f'{value:4.2f}:{self.history_length}'\n",
" # if isinstance(value, int) and value != 0:\n",
" # value = f'{value:4.2f}:{self.history_length}'\n",
" # labels[(self.get_name(), name)] = value\n",
" \n",
" def get_weights_labels_funcdata(self, labels):\n",
" for i in range(len(self.weights)):\n",
" link = self.get_link(i)\n",
" if isinstance(link, str):\n",
" name=link\n",
" else:\n",
" name = link.get_graph_name()\n",
" value = self.weights[i]\n",
" if isinstance(value, float):\n",
" value = f'{value:4.2f}:{self.history_length}'\n",
" if isinstance(value, int) and value != 0:\n",
" value = f'{value:4.2f}:{self.history_length}'\n",
" labels[(self.get_graph_name(), name)] = value\n",
" \n",
" def get_graph_name(self):\n",
" return f'{self.name}\\n{self.history_length}' \n",
" \n",
" # def get_weights_labels_funcdata(self, labels):\n",
" # for i in range(len(self.weights)):\n",
" # link = self.get_link(i)\n",
" # if isinstance(link, str):\n",
" # name=link\n",
" # else:\n",
" # name = link.get_graph_name()\n",
" # value = self.weights[i]\n",
" # if isinstance(value, float):\n",
" # value = f'{value:4.2f}:{self.history_length}'\n",
" # if isinstance(value, int) and value != 0:\n",
" # value = f'{value:4.2f}:{self.history_length}'\n",
" # labels[(self.get_graph_name(), name)] = value\n",
" \n",
" \n",
" class Factory:\n",
" def create(self): return DerivativeWeightedSum()\n",
" \n",
Expand Down
Loading

0 comments on commit ce8cf98

Please sign in to comment.