10 #include <boost/assert.hpp> 21 const bool biasEnabled,
23 const bool transposeWeights)
26 unsigned int outputSize = rOutputShape[1];
28 for (
unsigned int n = 0; n < rInputShape[0]; n++)
30 for (
unsigned int channelOutput = 0; channelOutput < outputSize; channelOutput++)
34 for (
unsigned int channelInput = 0; channelInput < K; channelInput++)
39 rWeightDecoder[channelOutput * K + channelInput];
40 weight = rWeightDecoder.
Get();
44 rWeightDecoder[channelInput * outputSize + channelOutput];
45 weight = rWeightDecoder.
Get();
48 rInputDecoder[n * K + channelInput];
49 outval += weight * rInputDecoder.
Get();
54 rBiasDecoder[channelOutput];
55 outval += rBiasDecoder.
Get();
58 rOutputEncoder[n * outputSize + channelOutput];
59 rOutputEncoder.
Set(outval);
void FullyConnected(const TensorShape &rInputShape, Decoder< float > &rInputDecoder, const TensorShape &rOutputShape, Encoder< float > &rOutputEncoder, Decoder< float > &rWeightDecoder, Decoder< float > &rBiasDecoder, const bool biasEnabled, const unsigned int K, const bool transposeWeights)
Performs a matrix multiplication and optionally adds a bias.
virtual IType Get() const =0
virtual void Set(IType right)=0