def _set_output_dim(self, n): last_node = self._flow[-1] if len(self._flow) == 1: self._flow[-1].output_dim = n elif last_node.output_dim is None: self._fix_nodes_dimensions() # check if it worked if last_node.output_dim is None: if last_node.input_dim is None: err = ("FlowNode can't set the dimension of the last " "node, because its input_dim is undefined (" "which could lead to inconsistent dimensions).") raise mdp.InconsistentDimException(err) # now we can safely try to set the dimension last_node.output_dim = n # the last_node dim is now set if n != last_node.output_dim: err = (("FlowNode can't be set to output_dim %d" % n) + " because the last internal node already has " + "output_dim %d." % last_node.output_dim) raise mdp.InconsistentDimException(err) self._output_dim = n
def _set_output_dim(self, n): if (self._input_dim is not None) and (self._input_dim != n): err = "output_dim must be equal to input_dim for this node." raise mdp.InconsistentDimException(err) self._input_dim = n self._output_dim = n