(self, X, shuffle=True, display_step=None)
return self
Training cycle.

        Parameters
        ----------
        X : ndarray, shape (n_samples, n_features)
            Matrix containing the data to be learned.

        Returns
        -------
        self : object
            Returns self.
Training cycle.
Training cycle .
def fit(self, X, shuffle=True, display_step=None):
        """Training cycle.

        Parameters
        ----------
        X : ndarray, shape (n_samples, n_features)
            Matrix containing the data to be learned.

        Returns
        -------
        self : object
            Returns self.
        """
        if display_step is None:
            display_step = self.log_every
        n_samples = X.shape[0]

        for epoch in range(self.num_epochs):
            if shuffle:
                indices = np.arange(len(X))
                self.random_state.shuffle(indices)
            avg_cost = 0.
            # Loop over all batches.
            start_idxs = range(
                0, len(X) - self.batch_size + 1, self.batch_size)
            for start_idx in start_idxs:
                if shuffle:
                    excerpt = indices[start_idx:start_idx + self.batch_size]
                else:
                    excerpt = slice(start_idx, start_idx + self.batch_size)
                batch = np.array(X[excerpt])

                # Fit training using batch data.
                cost = self.partial_fit(batch)
                # Compute average loss.
                avg_cost += cost / n_samples * self.batch_size

            if len(start_idxs) > 0:
                # Display logs per epoch step.
                if display_step and epoch % display_step == 0:
                    print("Epoch: {:d}".format(epoch + 1),
                          "cost: {:.4f}".format(avg_cost))

        return self
def fit ( self , X , shuffle = True , display_step = None ) : if display_step is None : display_step = self . log_every n_samples = X . shape [ 0 ] for epoch in range ( self . num_epochs ) : if shuffle : indices = np . arange ( len ( X ) ) self . random_state . shuffle ( indices ) avg_cost = 0. # Loop over all batches. start_idxs = range ( 0 , len ( X ) - self . batch_size + 1 , self . batch_size ) for start_idx in start_idxs : if shuffle : excerpt = indices [ start_idx : start_idx + self . batch_size ] else : excerpt = slice ( start_idx , start_idx + self . batch_size ) batch = np . array ( X [ excerpt ] ) # Fit training using batch data. cost = self . partial_fit ( batch ) # Compute average loss. avg_cost += cost / n_samples * self . batch_size if len ( start_idxs ) > 0 : # Display logs per epoch step. if display_step and epoch % display_step == 0 : print ( "Epoch: {:d}" . format ( epoch + 1 ) , "cost: {:.4f}" . format ( avg_cost ) ) return self