Gets the weights and returns them as a flat array.

        Returns:
            1D Array containing the flattened weights.
350525
def get_flat(self):
        
        self._check_sess()
        return np.concatenate([
            v.eval(session=self.sess).flatten()
            for v in self.variables.values()
        ])
380036
def _parse_weights(weight_args, default_weight=0.6):
    """"""
    weights_dict = {}
    r_group_weight = default_weight
    for weight_arg in weight_args:
        for weight_assignment in weight_arg.split(','):
            if '=' not in weight_assignment:
                raise ValueError(
                    'Invalid weight assignment: {}'.format(weight_assignment))

            key, value = weight_assignment.split('=', 1)
            value = float(value)
            if key == 'R':
                r_group_weight = value
            elif key == '*':
                default_weight = value
            elif hasattr(Atom, key):
                weights_dict[Atom(key)] = value
            else:
                raise ValueError('Invalid element: {}'.format(key))

    return weights_dict, r_group_weight, default_weight
1337556
def _weighting(weights, exponent):
    """"""
    if np.isscalar(weights):
        weighting = NumpyTensorSpaceConstWeighting(weights, exponent)
    elif weights is None:
        weighting = NumpyTensorSpaceConstWeighting(1.0, exponent)
    else:  # last possibility: make an array
        arr = np.asarray(weights)
        weighting = NumpyTensorSpaceArrayWeighting(arr, exponent)
    return weighting
1217325
public int getNumWeights() {
    if (weights == null) return 0;
    int numWeights = 0;
    for (double[] wts : weights) {
      numWeights += wts.length;
    }
    return numWeights;
  }
678321
def _compute_weights(self):
        

        n = self.n
        c = 1. / (n + 1)
        self.Wm = np.full(n + 1, c)
        self.Wc = self.Wm
846165
def arrayify(self):
        
        gene = []
        for layer in self.layers:
            if layer.type != 'Input':
                for i in range(layer.size):
                    gene.append( layer.weight[i] )
        for connection in self.connections:
            for i in range(connection.fromLayer.size):
                for j in range(connection.toLayer.size):
                    gene.append( connection.weight[i][j] )
        return gene
873606
def opt_weights(self):
        """"""
        return pd.DataFrame(self._xs, index=self.newidx, columns=self.cols)
69161
def S(self):
        
        S = np.array([[self._plane_width / self._vol_width, 0, 0],
                      [0, self._plane_height / self._vol_height, 0],
                      [0, 0, self._depth_scale / self._vol_depth]])
        return S
747700
def in_channels(m:nn.Module) -> List[int]:
    ""
    for l in flatten_model(m):
        if hasattr(l, 'weight'): return l.weight.shape[1]
    raise Exception('No weight layer')
328927
def raster_weights(self, **kwargs):
        
        if self.weights is None:
            self.weights = raster_weights(self.raster, **kwargs)
        pass
8150
def gradients(self):
        
        g = np.gradient(self.data.astype(np.float32))
        return g
1228821
def _flatten(cls, arr) -> List[float]:
        
        if isinstance(arr, cls.SCALAR_ACTION_TYPES):
            arr = [float(arr)]
        if isinstance(arr, np.ndarray):
            arr = arr.tolist()
        if len(arr) == 0:
            return arr
        if isinstance(arr[0], np.ndarray):
            arr = [item for sublist in arr for item in sublist.tolist()]
        if isinstance(arr[0], list):
            arr = [item for sublist in arr for item in sublist]
        arr = [float(x) for x in arr]
        return arr
580011
def uflat(self):
          # noqa
        aligned_arrays = [self[key].values[[(slice(None)
                                             if c in coords
                                             else None)
                                            for c in self._coords]].T
                          for key, coords in self.dependent_variables_info]
        return np.vstack(aligned_arrays).flatten("F")
193844
def _preprocess_inputs(x, weights):
    
    if weights is None:
        w_arr = np.ones(len(x))
    else:
        w_arr = np.array(weights)
    x_arr = np.array(x)
    if x_arr.ndim == 2:
        if w_arr.ndim == 1:
            w_arr = w_arr[:, np.newaxis]
    return x_arr, w_arr
206929
def weight(self, arr:Collection, is_item:bool=True):
        ""
        idx = self.get_idx(arr, is_item)
        m = self.model
        layer = m.i_weight if is_item else m.u_weight
        return layer(idx)
94704
def get_weights(self):
        
        self._check_sess()
        return {
            k: v.eval(session=self.sess)
            for k, v in self.variables.items()
        }
684639
def to_scales(val):
    
    res = []
    for i in val:
        if len(i) == 3:
            res.append((i[0], type(i[2])))
        else:
            try:
                res.append((i[0], i[3].dtype, i[2]))
            except AttributeError:
                res.append((i[0], type(i[3]), i[2]))

    dtype = np.dtype(res)

    scales = np.zeros((1, ), dtype=dtype)

    for i in val:
        try:
            scales[i[0]] = i[-1]
        except ValueError:
            scales[i[0]] = np.repeat(np.array(i[-1]), i[2][1]).reshape(i[2])

    return scales