phitodeep.model =============== .. py:module:: phitodeep.model Classes ------- .. autoapisummary:: phitodeep.model.Sequential phitodeep.model.SequentialBuilder Module Contents --------------- .. py:class:: Sequential(*layers, alpha=0.01, optimizer: phitodeep.optimization.optimizers.Optimizer = o.Adam(), batch_size=None, epochs=1000, loss_class=ls.MeanSquaredError()) .. py:attribute:: layers :value: [] .. py:attribute:: alpha :value: 0.01 .. py:attribute:: optimizer_type .. py:attribute:: batch_size :value: None .. py:attribute:: epochs :value: 1000 .. py:attribute:: loss_class .. py:method:: add(layer) -> None Add a layer to the network. .. py:method:: setoptimizer(optimizer) .. py:method:: setbatchsize(num) .. py:method:: setloss(loss_class) .. py:method:: train(X, y, X_test, y_test) Train the model using the specified optimizer and loss function. :param X: Training data. :type X: np.ndarray :param y: Training labels. :type y: np.ndarray :param X_test: Test data. :type X_test: np.ndarray :param y_test: Test labels. :type y_test: np.ndarray :returns: A list of tuples containing the training and test losses for each epoch. :rtype: list .. py:method:: predict(X) Forward pass through all layers. :param X: input array :returns: output after passing through all layers .. py:method:: backward(gradient) Backward pass through all layers. :param gradient: dL/dY from loss function (shape: batch_size x output_size) Propagates gradient backwards through all layers in reverse order. Each layer computes its parameter gradients, updates parameters, and returns the gradient for the previous layer. .. py:method:: __call__(X) Allow model(X) syntax. .. py:method:: summary() Print model architecture. .. py:method:: copy() Return a copy of the model. .. py:class:: SequentialBuilder Fluent API for building Sequential models. .. py:attribute:: layers :value: [] .. py:attribute:: alpha_value :value: 1 .. py:attribute:: optimizer_type .. py:attribute:: batch_size :value: None .. py:attribute:: epochs_value :value: 1000 .. py:attribute:: loss_class .. py:method:: flatten() Add a Flatten layer. .. py:method:: dense(input_size, output_size, initializer=He()) Add a Dense layer. .. py:method:: relu() Add a ReLU activation. .. py:method:: sigmoid() Add a Sigmoid activation. .. py:method:: tanh() Add a Tanh activation. .. py:method:: softmax() Add a Softmax activation. .. py:method:: elu(alpha_activation=1.0) Add an ELU activation. .. py:method:: optimizer(optimizer) Set the optimizer. .. py:method:: batch(num) Set the batch size. .. py:method:: alpha(num) Set the learning rate. .. py:method:: epochs(num) Set the number of epochs. .. py:method:: loss(loss_class) Set the loss function. .. py:method:: build() Build and return the Sequential model.