Python numpy.take() Examples

The following are 30 code examples for showing how to use numpy.take(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module numpy , or try the search function .

Example 1
Project: Traffic_sign_detection_YOLO   Author: AmeyaWagh   File: convolution.py    License: MIT License 6 votes vote down vote up
def recollect(self, w):
        if w is None:
            self.w = w
            return
        k = w['kernel']
        b = w['biases']
        k = np.take(k, self.inp, 2)
        k = np.take(k, self.out, 3)
        b = np.take(b, self.out)
        assert1 = k.shape == tuple(self.wshape['kernel'])
        assert2 = b.shape == tuple(self.wshape['biases'])
        assert assert1 and assert2, \
        'Dimension not matching in {} recollect'.format(
            self._signature)
        self.w['kernel'] = k
        self.w['biases'] = b 
Example 2
Project: Traffic_sign_detection_YOLO   Author: AmeyaWagh   File: convolution.py    License: MIT License 6 votes vote down vote up
def recollect(self, w):
        if w is None:
            self.w = w
            return
        idx = self.keep_idx
        k = w['kernel']
        b = w['biases']
        self.w['kernel'] = np.take(k, idx, 3) 
        self.w['biases'] = np.take(b, idx)
        if self.batch_norm:
            m = w['moving_mean']
            v = w['moving_variance']
            g = w['gamma']
            self.w['moving_mean'] = np.take(m, idx)
            self.w['moving_variance'] = np.take(v, idx)
            self.w['gamma'] = np.take(g, idx) 
Example 3
def _push_queue(self, data_list, labels):
        """Takes a list of numpy arrays for data,
        and a numpy array for labels.
        Converts to minibatches and puts it on the queue.
        """
        num_minibatches = 1+self.sample_ratio
        total_size = len(labels)
        slice_size = total_size / num_minibatches
        def slicer(x, s):
            idx = range(int(s*slice_size), int((s+1)*slice_size))
            return np.take(x,idx,0)

        for i in range(1+self.sample_ratio):
            nddata = [mx.nd.array(slicer(x,i)) for x in data_list]
            ndlabels = mx.nd.array(slicer(labels,i))
            batch = mx.io.DataBatch(nddata, [ndlabels], provide_data=self.provide_data,
                                    provide_label=self.provide_label)
            self._sampled_queue.append(batch) 
Example 4
def _shuffle_batch(self, data):
        # Takes a list of NDArrays.  Returns a shuffled version as numpy
        a = data[self.shuffle_data_idx].asnumpy()

        # Come up with a shuffled index
        batch_size = data[0].shape[0]
        si = np.arange(batch_size)
        np.random.shuffle(si)
        matches = (si == np.arange(batch_size)) # everywhere it didn't shuffle
        si -= matches  # Shifts down by 1 when true, ensuring it differs
        # Note shifting down by 1 works in python because -1 is a valid index.
        #Q: Is this shifting introducing bias?

        # Shuffle the data with the shuffle index
        shuf_a = np.take(a,si,0)  # like a[si,:] but general for ndarray's

        # Return similar datastructure to what we got.  Convert all to numpy
        out = [d.asnumpy() for d in data]
        out[self.shuffle_data_idx] = shuf_a
        return out 
Example 5
def recollect(self, w):
        if w is None:
            self.w = w
            return
        k = w['kernel']
        b = w['biases']
        k = np.take(k, self.inp, 2)
        k = np.take(k, self.out, 3)
        b = np.take(b, self.out)
        assert1 = k.shape == tuple(self.wshape['kernel'])
        assert2 = b.shape == tuple(self.wshape['biases'])
        assert assert1 and assert2, \
        'Dimension not matching in {} recollect'.format(
            self._signature)
        self.w['kernel'] = k
        self.w['biases'] = b 
Example 6
def recollect(self, w):
        if w is None:
            self.w = w
            return
        idx = self.keep_idx
        k = w['kernel']
        b = w['biases']
        self.w['kernel'] = np.take(k, idx, 3) 
        self.w['biases'] = np.take(b, idx)
        if self.batch_norm:
            m = w['moving_mean']
            v = w['moving_variance']
            g = w['gamma']
            self.w['moving_mean'] = np.take(m, idx)
            self.w['moving_variance'] = np.take(v, idx)
            self.w['gamma'] = np.take(g, idx) 
Example 7
Project: pyscf   Author: pyscf   File: eom_uccsd.py    License: Apache License 2.0 6 votes vote down vote up
def amplitudes_to_vector_eomsf(t1, t2, out=None):
    t1ab, t1ba = t1
    t2baaa, t2aaba, t2abbb, t2bbab = t2
    nocca, nvirb = t1ab.shape
    noccb, nvira = t1ba.shape

    otrila = np.tril_indices(nocca, k=-1)
    otrilb = np.tril_indices(noccb, k=-1)
    vtrila = np.tril_indices(nvira, k=-1)
    vtrilb = np.tril_indices(nvirb, k=-1)
    baaa = np.take(t2baaa.reshape(noccb*nocca,nvira*nvira),
                   vtrila[0]*nvira+vtrila[1], axis=1)
    abbb = np.take(t2abbb.reshape(nocca*noccb,nvirb*nvirb),
                   vtrilb[0]*nvirb+vtrilb[1], axis=1)
    vector = np.hstack((t1ab.ravel(), t1ba.ravel(),
                        baaa.ravel(), t2aaba[otrila].ravel(),
                        abbb.ravel(), t2bbab[otrilb].ravel()))
    return vector 
Example 8
Project: radiometric_normalization   Author: planetlabs   File: normalize.py    License: Apache License 2.0 6 votes vote down vote up
def apply_using_lut(input_band, transformation):
    '''Applies a linear transformation to an array using a look up table.
    This creates a uint16 array as the output and clips the output band
    to the range of a uint16.

    :param array input_band: A 2D array representing the image data of the
        a single band
    :param LinearTransformation transformation: A LinearTransformation
        (gain and offset)

    :returns: A 2D array of of the input_band with the transformation applied
    '''
    logging.info('Normalize: Applying linear transformation to band (uint16)')

    def _apply_lut(band, lut):
        '''Changes band intensity values based on intensity look up table (lut)
        '''
        if lut.dtype != band.dtype:
            raise Exception(
                'Band ({}) and lut ({}) must be the same data type.').format(
                band.dtype, lut.dtype)
        return numpy.take(lut, band, mode='clip')

    lut = _linear_transformation_to_lut(transformation)
    return _apply_lut(input_band, lut) 
Example 9
Project: pyGSTi   Author: pyGSTio   File: spamvec.py    License: Apache License 2.0 6 votes vote down vote up
def deriv_wrt_params(self, wrtFilter=None):
        """
        Construct a matrix whose columns are the derivatives of the SPAM vector
        with respect to a single param.  Thus, each column is of length
        get_dimension and there is one column per SPAM vector parameter.
        An empty 2D array in the StaticSPAMVec case (num_params == 0).

        Returns
        -------
        numpy array
            Array of derivatives, shape == (dimension, num_params)
        """
        dtype = complex if self._evotype == 'statevec' else 'd'
        derivMx = _np.zeros((self.dim, 0), dtype)
        if wrtFilter is None:
            return derivMx
        else:
            return _np.take(derivMx, wrtFilter, axis=1) 
Example 10
Project: pyGSTi   Author: pyGSTio   File: spamvec.py    License: Apache License 2.0 6 votes vote down vote up
def deriv_wrt_params(self, wrtFilter=None):
        """
        Construct a matrix whose columns are the derivatives of the SPAM vector
        with respect to a single param.  Thus, each column is of length
        get_dimension and there is one column per SPAM vector parameter.

        Returns
        -------
        numpy array
            Array of derivatives, shape == (dimension, num_params)
        """
        if self._evotype == "statevec":
            derivMx = _np.concatenate((_np.identity(self.dim, complex),
                                       1j * _np.identity(self.dim, complex)), axis=1)
        else:
            derivMx = _np.identity(self.dim, 'd')

        if wrtFilter is None:
            return derivMx
        else:
            return _np.take(derivMx, wrtFilter, axis=1) 
Example 11
Project: pyGSTi   Author: pyGSTio   File: spamvec.py    License: Apache License 2.0 6 votes vote down vote up
def deriv_wrt_params(self, wrtFilter=None):
        """
        Construct a matrix whose columns are the derivatives of the SPAM vector
        with respect to a single param.  Thus, each column is of length
        get_dimension and there is one column per SPAM vector parameter.

        Returns
        -------
        numpy array
            Array of derivatives, shape == (dimension, num_params)
        """
        derivMx = _np.identity(self.dim, 'd')  # TP vecs assumed real
        derivMx = derivMx[:, 1:]  # remove first col ( <=> first-el parameters )
        if wrtFilter is None:
            return derivMx
        else:
            return _np.take(derivMx, wrtFilter, axis=1) 
Example 12
Project: pyGSTi   Author: pyGSTio   File: spamvec.py    License: Apache License 2.0 6 votes vote down vote up
def hessian_wrt_params(self, wrtFilter1=None, wrtFilter2=None):
        """
        Construct the Hessian of this SPAM vector with respect to its parameters.

        This function returns a tensor whose first axis corresponds to the
        flattened operation matrix and whose 2nd and 3rd axes correspond to the
        parameters that are differentiated with respect to.

        Parameters
        ----------
        wrtFilter1, wrtFilter2 : list
            Lists of indices of the paramters to take first and second
            derivatives with respect to.  If None, then derivatives are
            taken with respect to all of the vectors's parameters.

        Returns
        -------
        numpy array
            Hessian with shape (dimension, num_params1, num_params2)
        """
        raise NotImplementedError("TODO: add hessian computation for CPTPSPAMVec") 
Example 13
Project: starfm4py   Author: nmileva   File: starfm4py.py    License: GNU General Public License v3.0 6 votes vote down vote up
def block2row(array, row, folder, block_id=None):
    if array.shape[0] == windowSize:
        # Parameters	
        name_string = str(block_id[0] + 1)
        m,n = array.shape
        u = m + 1 - windowSize
        v = n + 1 - windowSize

    	# Get Starting block indices
        start_idx = np.arange(u)[:,None]*n + np.arange(v)

    	# Get offsetted indices across the height and width of input array
        offset_idx = np.arange(windowSize)[:,None]*n + np.arange(windowSize)

    	# Get all actual indices & index into input array for final output
        flat_array = np.take(array,start_idx.ravel()[:,None] + offset_idx.ravel())

        # Save to (dask) array in .zarr format
        file_name = path + folder + name_string + 'r' + row + '.zarr'
        zarr.save(file_name, flat_array)
    
    return array


# Divide an image in overlapping blocks 
Example 14
Project: Traffic-Signs-and-Object-Detection   Author: dark-archerx   File: convolution.py    License: GNU General Public License v3.0 6 votes vote down vote up
def recollect(self, w):
        if w is None:
            self.w = w
            return
        k = w['kernel']
        b = w['biases']
        k = np.take(k, self.inp, 2)
        k = np.take(k, self.out, 3)
        b = np.take(b, self.out)
        assert1 = k.shape == tuple(self.wshape['kernel'])
        assert2 = b.shape == tuple(self.wshape['biases'])
        assert assert1 and assert2, \
        'Dimension not matching in {} recollect'.format(
            self._signature)
        self.w['kernel'] = k
        self.w['biases'] = b 
Example 15
Project: Traffic-Signs-and-Object-Detection   Author: dark-archerx   File: convolution.py    License: GNU General Public License v3.0 6 votes vote down vote up
def recollect(self, w):
        if w is None:
            self.w = w
            return
        idx = self.keep_idx
        k = w['kernel']
        b = w['biases']
        self.w['kernel'] = np.take(k, idx, 3) 
        self.w['biases'] = np.take(b, idx)
        if self.batch_norm:
            m = w['moving_mean']
            v = w['moving_variance']
            g = w['gamma']
            self.w['moving_mean'] = np.take(m, idx)
            self.w['moving_variance'] = np.take(v, idx)
            self.w['gamma'] = np.take(g, idx) 
Example 16
Project: recruit   Author: Frank-qlu   File: timer_comparison.py    License: Apache License 2.0 6 votes vote down vote up
def test_4(self):
        """
        Test of take, transpose, inner, outer products.

        """
        x = self.arange(24)
        y = np.arange(24)
        x[5:6] = self.masked
        x = x.reshape(2, 3, 4)
        y = y.reshape(2, 3, 4)
        assert self.allequal(np.transpose(y, (2, 0, 1)), self.transpose(x, (2, 0, 1)))
        assert self.allequal(np.take(y, (2, 0, 1), 1), self.take(x, (2, 0, 1), 1))
        assert self.allequal(np.inner(self.filled(x, 0), self.filled(y, 0)),
                            self.inner(x, y))
        assert self.allequal(np.outer(self.filled(x, 0), self.filled(y, 0)),
                            self.outer(x, y))
        y = self.array(['abc', 1, 'def', 2, 3], object)
        y[2] = self.masked
        t = self.take(y, [0, 3, 4])
        assert t[0] == 'abc'
        assert t[1] == 2
        assert t[2] == 3 
Example 17
Project: recruit   Author: Frank-qlu   File: test_old_ma.py    License: Apache License 2.0 6 votes vote down vote up
def test_testTakeTransposeInnerOuter(self):
        # Test of take, transpose, inner, outer products
        x = arange(24)
        y = np.arange(24)
        x[5:6] = masked
        x = x.reshape(2, 3, 4)
        y = y.reshape(2, 3, 4)
        assert_(eq(np.transpose(y, (2, 0, 1)), transpose(x, (2, 0, 1))))
        assert_(eq(np.take(y, (2, 0, 1), 1), take(x, (2, 0, 1), 1)))
        assert_(eq(np.inner(filled(x, 0), filled(y, 0)),
                   inner(x, y)))
        assert_(eq(np.outer(filled(x, 0), filled(y, 0)),
                   outer(x, y)))
        y = array(['abc', 1, 'def', 2, 3], object)
        y[2] = masked
        t = take(y, [0, 3, 4])
        assert_(t[0] == 'abc')
        assert_(t[1] == 2)
        assert_(t[2] == 3) 
Example 18
Project: recruit   Author: Frank-qlu   File: test_old_ma.py    License: Apache License 2.0 6 votes vote down vote up
def test_testArrayMethods(self):
        a = array([1, 3, 2])
        assert_(eq(a.any(), a._data.any()))
        assert_(eq(a.all(), a._data.all()))
        assert_(eq(a.argmax(), a._data.argmax()))
        assert_(eq(a.argmin(), a._data.argmin()))
        assert_(eq(a.choose(0, 1, 2, 3, 4),
                           a._data.choose(0, 1, 2, 3, 4)))
        assert_(eq(a.compress([1, 0, 1]), a._data.compress([1, 0, 1])))
        assert_(eq(a.conj(), a._data.conj()))
        assert_(eq(a.conjugate(), a._data.conjugate()))
        m = array([[1, 2], [3, 4]])
        assert_(eq(m.diagonal(), m._data.diagonal()))
        assert_(eq(a.sum(), a._data.sum()))
        assert_(eq(a.take([1, 2]), a._data.take([1, 2])))
        assert_(eq(m.transpose(), m._data.transpose())) 
Example 19
Project: recruit   Author: Frank-qlu   File: test_core.py    License: Apache License 2.0 6 votes vote down vote up
def test_generic_methods(self):
        # Tests some MaskedArray methods.
        a = array([1, 3, 2])
        assert_equal(a.any(), a._data.any())
        assert_equal(a.all(), a._data.all())
        assert_equal(a.argmax(), a._data.argmax())
        assert_equal(a.argmin(), a._data.argmin())
        assert_equal(a.choose(0, 1, 2, 3, 4), a._data.choose(0, 1, 2, 3, 4))
        assert_equal(a.compress([1, 0, 1]), a._data.compress([1, 0, 1]))
        assert_equal(a.conj(), a._data.conj())
        assert_equal(a.conjugate(), a._data.conjugate())

        m = array([[1, 2], [3, 4]])
        assert_equal(m.diagonal(), m._data.diagonal())
        assert_equal(a.sum(), a._data.sum())
        assert_equal(a.take([1, 2]), a._data.take([1, 2]))
        assert_equal(m.transpose(), m._data.transpose()) 
Example 20
Project: recruit   Author: Frank-qlu   File: test_core.py    License: Apache License 2.0 6 votes vote down vote up
def test_take(self):
        # Tests take
        x = masked_array([10, 20, 30, 40], [0, 1, 0, 1])
        assert_equal(x.take([0, 0, 3]), masked_array([10, 10, 40], [0, 0, 1]))
        assert_equal(x.take([0, 0, 3]), x[[0, 0, 3]])
        assert_equal(x.take([[0, 1], [0, 1]]),
                     masked_array([[10, 20], [10, 20]], [[0, 1], [0, 1]]))

        # assert_equal crashes when passed np.ma.mask
        assert_(x[1] is np.ma.masked)
        assert_(x.take(1) is np.ma.masked)

        x = array([[10, 20, 30], [40, 50, 60]], mask=[[0, 0, 1], [1, 0, 0, ]])
        assert_equal(x.take([0, 2], axis=1),
                     array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]]))
        assert_equal(take(x, [0, 2], axis=1),
                     array([[10, 30], [40, 60]], mask=[[0, 1], [1, 0]])) 
Example 21
Project: recruit   Author: Frank-qlu   File: test_internals.py    License: Apache License 2.0 6 votes vote down vote up
def test_take(self):
        def assert_take_ok(mgr, axis, indexer):
            mat = mgr.as_array()
            taken = mgr.take(indexer, axis)
            tm.assert_numpy_array_equal(np.take(mat, indexer, axis),
                                        taken.as_array(), check_dtype=False)
            tm.assert_index_equal(mgr.axes[axis].take(indexer),
                                  taken.axes[axis])

        for mgr in self.MANAGERS:
            for ax in range(mgr.ndim):
                # take/fancy indexer
                assert_take_ok(mgr, ax, [])
                assert_take_ok(mgr, ax, [0, 0, 0])
                assert_take_ok(mgr, ax, lrange(mgr.shape[ax]))

                if mgr.shape[ax] >= 3:
                    assert_take_ok(mgr, ax, [0, 1, 2])
                    assert_take_ok(mgr, ax, [-1, -2, -3]) 
Example 22
Project: recruit   Author: Frank-qlu   File: test_nanops.py    License: Apache License 2.0 6 votes vote down vote up
def check_bool(self, func, value, correct, *args, **kwargs):
        while getattr(value, 'ndim', True):
            try:
                res0 = func(value, *args, **kwargs)
                if correct:
                    assert res0
                else:
                    assert not res0
            except BaseException as exc:
                exc.args += ('dim: %s' % getattr(value, 'ndim', value), )
                raise
            if not hasattr(value, 'ndim'):
                break
            try:
                value = np.take(value, 0, axis=-1)
            except ValueError:
                break 
Example 23
Project: recruit   Author: Frank-qlu   File: categorical.py    License: Apache License 2.0 6 votes vote down vote up
def get_values(self):
        """
        Return the values.

        For internal compatibility with pandas formatting.

        Returns
        -------
        values : numpy array
            A numpy array of the same dtype as categorical.categories.dtype or
            Index if datetime / periods
        """
        # if we are a datetime and period index, return Index to keep metadata
        if is_datetimelike(self.categories):
            return self.categories.take(self._codes, fill_value=np.nan)
        elif is_integer_dtype(self.categories) and -1 in self._codes:
            return self.categories.astype("object").take(self._codes,
                                                         fill_value=np.nan)
        return np.array(self) 
Example 24
Project: recruit   Author: Frank-qlu   File: merge.py    License: Apache License 2.0 6 votes vote down vote up
def _left_join_on_index(left_ax, right_ax, join_keys, sort=False):
    if len(join_keys) > 1:
        if not ((isinstance(right_ax, MultiIndex) and
                 len(join_keys) == right_ax.nlevels)):
            raise AssertionError("If more than one join key is given then "
                                 "'right_ax' must be a MultiIndex and the "
                                 "number of join keys must be the number of "
                                 "levels in right_ax")

        left_indexer, right_indexer = \
            _get_multiindex_indexer(join_keys, right_ax, sort=sort)
    else:
        jkey = join_keys[0]

        left_indexer, right_indexer = \
            _get_single_indexer(jkey, right_ax, sort=sort)

    if sort or len(left_ax) != len(left_indexer):
        # if asked to sort or there are 1-to-many matches
        join_index = left_ax.take(left_indexer)
        return join_index, left_indexer, right_indexer

    # left frame preserves order & length of its index
    return left_ax, None, right_indexer 
Example 25
Project: ibllib   Author: int-brain-lab   File: fourier.py    License: MIT License 6 votes vote down vote up
def fexpand(x, ns=1, axis=None):
    """
    Reconstructs full spectrum from positive frequencies
    Works on the last dimension (contiguous in c-stored array)

    :param x: numpy.ndarray
    :param axis: axis along which to perform reduction (last axis by default)
    :return: numpy.ndarray
    """
    if axis is None:
        axis = x.ndim - 1
    # dec = int(ns % 2) * 2 - 1
    # xcomp = np.conj(np.flip(x[..., 1:x.shape[-1] + dec], axis=axis))
    ilast = int((ns + (ns % 2)) / 2)
    xcomp = np.conj(np.flip(np.take(x, np.arange(1, ilast), axis=axis), axis=axis))
    return np.concatenate((x, xcomp), axis=axis) 
Example 26
Project: EasyRL   Author: alibaba   File: buffer.py    License: Apache License 2.0 6 votes vote down vote up
def _encode_sample(self, idxes):
        idxes = np.asarray(idxes)

        obs = np.take(self._obs, indices=idxes, axis=0)
        actions = np.take(self._actions, indices=idxes, axis=0)
        rewards = np.take(self._rewards, indices=idxes, axis=0)
        next_obs = np.take(self._next_obs, indices=idxes, axis=0)
        dones = np.take(self._dones, indices=idxes, axis=0)

        batch_data = dict(
            obs=obs,
            actions=actions,
            rewards=rewards,
            dones=dones,
            next_obs=next_obs)

        return batch_data 
Example 27
Project: deepchem   Author: deepchem   File: donkey.py    License: MIT License 6 votes vote down vote up
def load_dataset(filename, whiten=False):
  f = open(filename, 'r')
  features = []
  labels = []
  tracer = 0
  for line in f:
    if tracer == 0:
      tracer += 1
      continue
    splits =  line[:-1].split(',')
    features.append(splits[-1])
    labels.append(float(splits[-2]))
  features = np.array(features)
  labels = np.array(labels, dtype='float32').reshape(-1, 1)

  train_ind, val_ind, test_ins = split(features)

  train_features = np.take(features, train_ind)
  train_labels = np.take(labels, train_ind)
  val_features = np.take(features, val_ind)
  val_labels = np.take(labels, val_ind)
  
  return train_features, train_labels, val_features, val_labels 
Example 28
Project: typhon   Author: atmtools   File: common.py    License: MIT License 6 votes vote down vote up
def interpolate_halflevels(x, axis=0):
    """Returns the linear inteprolated halflevels for given array.

    Parameters:
        x (ndarray): Data array.
        axis (int): Axis to interpolate along.

    Returns:
        ndarray: Values at halflevels.

    Examples:
        >>> interpolate_halflevels([0, 1, 2, 4])
        array([ 0.5,  1.5,  3. ])
    """
    return (np.take(x, range(1, np.shape(x)[axis]), axis=axis) +
            np.take(x, range(0, np.shape(x)[axis] - 1), axis=axis)) / 2 
Example 29
Project: Traffic_sign_detection_YOLO   Author: AmeyaWagh   File: connected.py    License: MIT License 5 votes vote down vote up
def recollect(self, val):
        w = val['weights']
        b = val['biases']
        if w is None: self.w = val; return
        w = np.take(w, self.inp, 0)
        w = np.take(w, self.out, 1)
        b = np.take(b, self.out)
        assert1 = w.shape == tuple(self.wshape['weights'])
        assert2 = b.shape == tuple(self.wshape['biases'])
        assert assert1 and assert2, \
        'Dimension does not match in {} recollect'.format(
            self._signature)
        
        self.w['weights'] = w
        self.w['biases'] = b 
Example 30
Project: Traffic_sign_detection_YOLO   Author: AmeyaWagh   File: connected.py    License: MIT License 5 votes vote down vote up
def recollect(self, val):
        w = val['weights']
        b = val['biases']
        if w is None: self.w = val; return
        if self.inp_idx is not None:
            w = np.take(w, self.inp_idx, 0)
            
        keep_b = np.take(b, self.keep)
        keep_w = np.take(w, self.keep, 1)
        train_b = b[self.train:]
        train_w = w[:, self.train:]
        self.w['biases'] = np.concatenate(
            (keep_b, train_b), axis = 0)
        self.w['weights'] = np.concatenate(
            (keep_w, train_w), axis = 1)