网页
综合
更新时间 2026-11-17 01:39:04
All symbols - @am/neuralnetwork - JSR
自动蜘蛛
jsr.io
正文约 3604 字
A simple neural network library for JavaScript and TypeScript.
Represents a neural network model composed of a sequence of layers.
Adds a layer to the model.
Configures the model for training.
Evaluates the model on a validation dataset.
Trains the model for a fixed number of epochs (iterations on a dataset).
Retrieves the configuration of the model.
Retrieves the layers of the model.
Loads a model from a JSON string.
Generates output predictions for the input samples.
Retrieves the number of layers in the model.
Abstract base class for activation function layers. All activation layers must implement the forward and backward methods.
Performs the backward pass of the activation function. Calculates the gradient of the loss with respect to the input of this layer.
Performs the forward pass of the activation function.
Returns the type of this layer.
Returns the type of the layer.
Represents a fully connected (dense) layer in a neural network. Implements both Layer and TrainableLayer interfaces.
Performs the backward pass (backpropagation) through the dense layer. Calculates the gradient of the loss with respect to the layer's input.
Performs the forward pass through the dense layer. Output = Input * Weights + Biases
Returns the configuration of the layer.
Returns the number of input units.
Returns the name of the layer.
Returns the number of output units.
Calculates the gradients of the loss with respect to the layer's weights and biases. dL/dW_ij = dL/dY_j * X_i dL/dB_j = dL/dY_j
Retrieves the current weights and biases of the layer.
Updates the layer's weights and biases.
Rectified Linear Unit (ReLU) activation function. Outputs the input directly if it is positive, otherwise, it outputs zero. Formula: ReLU(x) = max(0, x)
Computes the gradient of the loss with respect to the input of the ReLU layer. The derivative of ReLU ReLU(x) is 1 if x > 0, and 0 otherwise.
Applies the ReLU function element-wise to the input. ReLU(x) = max(0, x)
Sigmoid activation function. Outputs values between 0 and 1. Formula: S(x) = 1 / (1 + e^(-x))
Computes the gradient of the loss with respect to the input of the sigmoid layer. The derivative of sigmoid S(x) is S(x) * (1 - S(x)).
Applies the sigmoid function element-wise to the input. S(x) = 1 / (1 + e^(-x))
Softmax activation function. Typically used in the output layer of a multi-class classification network. Converts a vector of K real numbers into a probability distribution of K possible outcomes. Formula: Softmax(x_i) = e^(x_i) / sum(e^(x_j)) for j = 1 to K.
Computes the gradient of the loss with respect to the input of the Softmax layer. The Jacobian of the Softmax function is a bit more complex. If i == j, dS_i / dZ_j = S_i * (1 - S_j). If i != j, dS_i / dZ_j = -S_i * S_j. This method computes dL/dZ_j = sum_i (dL/dS_i * dS_i/dZ_j). For a single sample, dL/dZ_j = S_j * (dL/dS_j - sum_k(dL/dS_k * S_k)).
Applies the Softmax function to each row of the input. Numerical stability is improved by subtracting the maximum value from each input row before exponentiation.
Hyperbolic Tangent (Tanh) activation function. Outputs values between -1 and 1. Formula: tanh(x) = (e^x - e^(-x)) / (e^x + e^(-x))
Computes the gradient of the loss with respect to the input of the Tanh layer. The derivative of tanh(x) is 1 - tanh^2(x).
Applies the Tanh function element-wise to the input. tanh(x) = (e^x - e^(-x)) / (e^x + e^(-x))
BinaryCrossEntropyLoss calculates the binary cross-entropy loss between predictions and target values. This loss is commonly used for binary classification tasks.
Calculates the binary cross-entropy loss.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。