neural_network.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:Optimus 作者: Yatoom 项目源码 文件源码
def fit(self, X, y):
        """
        Fit on X.
        :param X: {array-like, sparse matrix}, shape (n_samples, n_features). Input data, where `n_samples` is the 
        number of samples and `n_features` is the number of features.
        :return: Returns self
        """

        # Numpy
        X = np.array(X)
        y = np.array(y)

        # Check that X and y have correct shape
        X, y = check_X_y(X, y)

        # Store the classes seen during fit
        self.classes_ = unique_labels(y)

        # Store so that we know what we fitted on
        self.X_ = X
        self.y_ = y

        # Get dimensions
        input_dim = X.shape[1]
        output_dim = len(self.classes_)

        # Create a model if needed
        if (input_dim, output_dim) != self.io:
            self.model = self._build(input_dim, output_dim)

        self.model.fit(X, y, batch_size=self.batch_size, epochs=self.epochs, verbose=self.verbose)

        # Return the classifier
        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号