fully_connected¶
-
fully_connected(data=None, weight=None, bias=None, num_hidden=_Null, no_bias=_Null, flatten=_Null, out=None, name=None, **kwargs)¶ Applies a linear transformation: \(Y = XW^T + b\).
If
flattenis set to be true, then the shapes are:- data: (batch_size, x1, x2, …, xn)
- weight: (num_hidden, x1 * x2 * … * xn)
- bias: (num_hidden,)
- out: (batch_size, num_hidden)
If
flattenis set to be false, then the shapes are:- data: (x1, x2, …, xn, input_dim)
- weight: (num_hidden, input_dim)
- bias: (num_hidden,)
- out: (x1, x2, …, xn, num_hidden)
The learnable parameters include both
weightandbias.If
no_biasis set to be true, then thebiasterm is ignored.Note
The sparse support for FullyConnected is limited to forward evaluation with row_sparse weight and bias, where the length of weight.indices and bias.indices must be equal to num_hidden. This could be useful for model inference with row_sparse weights trained with importance sampling or noise contrastive estimation.
To compute linear transformation with ‘csr’ sparse data, sparse.dot is recommended instead of sparse.FullyConnected.
Defined in src/operator/nn/fully_connected.cc:L291
Parameters: - data : ndarray
Input data.
- weight : ndarray
Weight matrix.
- bias : ndarray
Bias parameter.
- num_hidden : int, required
Number of hidden nodes of the output.
- no_bias : boolean, optional, default=0
Whether to disable bias parameter.
- flatten : boolean, optional, default=1
Whether to collapse all but the first axis of the input data tensor.
- out : ndarray, optional
The output ndarray to hold the result.
Returns: - out : ndarray or list of ndarrays
The output of this function.