Standard Function implementations

Chainer provides basic Function implementations in the chainer.functions package. Most of them are wrapped by plain Python functions, which users should use.

Note

As of v1.5, the concept of parameterized functions are gone, and they are replaced by corresponding Link implementations. They are still put in the functions namespace for backward compatibility, though it is strongly recommended to use them via the chainer.links package.

Activation functions

chainer.functions.clipped_relu Clipped Rectifier Unit function.
chainer.functions.crelu Concatenated Rectified Linear Unit function.
chainer.functions.elu Exponential Linear Unit function.
chainer.functions.hard_sigmoid Element-wise hard-sigmoid function.
chainer.functions.leaky_relu Leaky Rectified Linear Unit function.
chainer.functions.log_softmax Channel-wise log-softmax function.
chainer.functions.lstm Long Short-Term Memory units as an activation function.
chainer.functions.maxout Maxout activation function.
chainer.functions.prelu Parametric ReLU function.
chainer.functions.relu Rectified Linear Unit function.
chainer.functions.selu Scaled Exponential Linear Unit function.
chainer.functions.sigmoid Element-wise sigmoid logistic function.
chainer.functions.slstm S-LSTM units as an activation function.
chainer.functions.softmax Softmax function.
chainer.functions.softplus Element-wise softplus function.
chainer.functions.tanh Elementwise hyperbolic tangent function.
chainer.functions.tree_lstm TreeLSTM unit as an activation function.

Array manipulations

chainer.functions.broadcast Broadcast given variables.
chainer.functions.broadcast_to Broadcast a given variable to a given shape.
chainer.functions.cast Cast an input variable to a given type.
chainer.functions.concat Concatenates given variables along an axis.
chainer.functions.copy Copies the input variable onto the specified device.
chainer.functions.depth2space Computes the depth2space transformation for subpixel calculations.
chainer.functions.dstack Concatenate variables along third axis (depth wise).
chainer.functions.expand_dims Expands dimensions of an input variable without copy.
chainer.functions.flatten Flatten a given array into one dimension.
chainer.functions.flip Flips an input variable in reverse order along the given axis.
chainer.functions.fliplr Flip array in the left/right direction.
chainer.functions.flipud Flip array in the up/down direction.
chainer.functions.get_item Extract elements from array with specified shape, axes and offsets.
chainer.functions.hstack Concatenate variables horizontally (column wise).
chainer.functions.im2col Extract patches from an image based on the filter.
chainer.functions.pad Pad an input variable.
chainer.functions.pad_sequence Pad given arrays to make a matrix.
chainer.functions.permutate Permutates a given variable along an axis.
chainer.functions.reshape Reshapes an input variable without copy.
chainer.functions.resize_images Resize images to the given shape.
chainer.functions.rollaxis Roll the axis backwards to the given position.
chainer.functions.select_item Select elements stored in given indices.
chainer.functions.separate Separates an array along a given axis.
chainer.functions.space2depth Computes the space2depth transformation for subpixel calculations.
chainer.functions.spatial_transformer_grid 2D Spatial Transformer grid.
chainer.functions.spatial_transformer_sampler 2D Spatial Transformer sampler.
chainer.functions.split_axis Splits given variables along an axis.
chainer.functions.squeeze Remove demensions of size one from the shape of a ndarray.
chainer.functions.stack Concatenate variables along a new axis.
chainer.functions.swapaxes Swap two axes of a variable.
chainer.functions.tile Construct an array by tiling a given array.
chainer.functions.transpose Permute the dimensions of an input variable without copy.
chainer.functions.transpose_sequence Transpose a list of Variables.
chainer.functions.vstack Concatenate variables vertically (row wise).
chainer.functions.where Choose elements depending on condition.

Neural network connections

chainer.functions.bilinear Applies a bilinear function based on given parameters.
chainer.functions.convolution_2d Two-dimensional convolution function.
chainer.functions.convolution_nd N-dimensional convolution function.
chainer.functions.deconvolution_2d Two dimensional deconvolution function.
chainer.functions.deconvolution_nd N-dimensional deconvolution function.
chainer.functions.depthwise_convolution_2d Two-dimensional depthwise convolution function.
chainer.functions.dilated_convolution_2d Two-dimensional dilated convolution function.
chainer.functions.embed_id Efficient linear function for one-hot input.
chainer.functions.linear Linear function, or affine transformation.
chainer.functions.n_step_bigru Stacked Bi-directional Gated Recurrent Unit function.
chainer.functions.n_step_bilstm Stacked Bi-directional Long Short-Term Memory function.
chainer.functions.n_step_birnn Stacked Bi-directional RNN function for sequence inputs.
chainer.functions.n_step_gru Stacked Uni-directional Gated Recurrent Unit function.
chainer.functions.n_step_lstm Stacked Uni-directional Long Short-Term Memory function.
chainer.functions.n_step_rnn Stacked Uni-directional RNN function for sequence inputs.

Evaluation functions

chainer.functions.accuracy Computes multiclass classification accuracy of the minibatch.
chainer.functions.binary_accuracy Computes binary classification accuracy of the minibatch.
chainer.functions.classification_summary Calculates Precision, Recall, F beta Score, and support.
chainer.functions.r2_score Computes R^2(coefficient of determination) regression score function.

Loss functions

chainer.functions.bernoulli_nll Computes the negative log-likelihood of a Bernoulli distribution.
chainer.functions.black_out BlackOut loss function.
chainer.functions.connectionist_temporal_classification Connectionist Temporal Classification loss function.
chainer.functions.contrastive Computes contrastive loss.
chainer.functions.crf1d Calculates negative log-likelihood of linear-chain CRF.
chainer.functions.argmax_crf1d Computes a state that maximizes a joint probability of the given CRF.
chainer.functions.cross_covariance Computes the sum-squared cross-covariance penalty between y and z
chainer.functions.gaussian_kl_divergence Computes the KL-divergence of Gaussian variables from the standard one.
chainer.functions.gaussian_nll Computes the negative log-likelihood of a Gaussian distribution.
chainer.functions.hinge Computes the hinge loss for a one-of-many classification task.
chainer.functions.huber_loss Loss function which is less sensitive to outliers in data than MSE.
chainer.functions.mean_absolute_error Mean absolute error function.
chainer.functions.mean_squared_error Mean squared error function.
chainer.functions.negative_sampling Negative sampling loss function.
chainer.functions.sigmoid_cross_entropy Computes cross entropy loss for pre-sigmoid activations.
chainer.functions.softmax_cross_entropy Computes cross entropy loss for pre-softmax activations.
chainer.functions.squared_error Squared error function.
chainer.functions.triplet Computes triplet loss.

Mathematical functions

chainer.functions.arccos Elementwise arccosine function.
chainer.functions.arcsin Elementwise arcsine function.
chainer.functions.arctan Elementwise arctangent function.
chainer.functions.arctan2 Elementwise arctangent function with two arguments.
chainer.functions.argmax Returns index which holds maximum of array elements over a given axis.
chainer.functions.argmin Returns index which holds minimum of array elements over a given axis.
chainer.functions.average Calculate weighted average of array elements over a given axis.
chainer.functions.batch_inv Computes the inverse of a batch of square matrices.
chainer.functions.batch_l2_norm_squared L2 norm (a.k.a. Euclidean norm) squared.
chainer.functions.batch_matmul Computes the batch matrix multiplications of two sets of arrays.
chainer.functions.bias Elementwise summation with broadcasting.
chainer.functions.ceil Elementwise ceil function.
chainer.functions.clip Clips (limits) elements of input variable.
chainer.functions.cos Elementwise cos function.
chainer.functions.cosh Elementwise hyperbolic cosine function.
chainer.functions.exp Elementwise exponential function.
chainer.functions.fix Elementwise fix function.
chainer.functions.fmod Elementwise mod function.
chainer.functions.floor Elementwise floor function.
chainer.functions.identity Just returns input variables.
chainer.functions.inv Computes the inverse of square matrix.
chainer.functions.linear_interpolate Elementwise linear-interpolation function.
chainer.functions.log Elementwise natural logarithm function.
chainer.functions.log10 Elementwise logarithm function to the base 10.
chainer.functions.log1p Elementwise natural logarithm plus one function.
chainer.functions.log2 Elementwise logarithm function to the base 2.
chainer.functions.logsumexp Log-sum-exp of array elements over a given axis.
chainer.functions.matmul Computes the matrix multiplication of two arrays.
chainer.functions.max Maximum of array elements over a given axis.
chainer.functions.maximum Element-wise maximum of input variables.
chainer.functions.mean Calculate weighted average of array elements over a given axis.
chainer.functions.min Minimum of array elements over a given axis.
chainer.functions.minimum Element-wise minimum of input variables.
chainer.functions.prod Product of array elements over a given axis.
chainer.functions.rsqrt Computes elementwise reciprocal of square root of input \(x_i\).
chainer.functions.scale Elementwise product with broadcasting.
chainer.functions.sin Elementwise sin function.
chainer.functions.sinh Elementwise hyperbolic sine function.
chainer.functions.sqrt Elementwise square root function.
chainer.functions.square Elementwise square function.
chainer.functions.squared_difference Squared difference of input variables.
chainer.functions.sum Sum of array elements over a given axis.
chainer.functions.tanh Elementwise hyperbolic tangent function.
chainer.functions.tan Elementwise tan function.

Noise injections

chainer.functions.dropout Drops elements of input variable randomly.
chainer.functions.gaussian Gaussian sampling function.
chainer.functions.simplified_dropconnect Linear unit regularized by simplified dropconnect.

Normalization functions

chainer.functions.batch_normalization Batch normalization function.
chainer.functions.fixed_batch_normalization Batch normalization function with fixed statistics.
chainer.functions.layer_normalization Layer normalization.
chainer.functions.local_response_normalization Local response normalization across neighboring channels.
chainer.functions.normalize L2 norm squared (a.k.a. Euclidean norm).

Spatial pooling

chainer.functions.average_pooling_2d Spatial average pooling function.
chainer.functions.average_pooling_nd N-dimensionally spatial average pooling function.
chainer.functions.max_pooling_2d Spatial max pooling function.
chainer.functions.max_pooling_nd N-dimensionally spatial max pooling function.
chainer.functions.roi_pooling_2d Spatial Region of Interest (ROI) pooling function.
chainer.functions.spatial_pyramid_pooling_2d Spatial pyramid pooling function.
chainer.functions.unpooling_2d Inverse operation of pooling for 2d array.
chainer.functions.upsampling_2d Upsampling using pooling indices.

Utility functions

chainer.functions.forget Calls a function without storing intermediate results.