Conv2d constructor
Conv2d({})
Implementation
Conv2d({
required this.inChannels,
required this.outChannels,
required this.kernelSize,
this.stride = 1,
this.padding = 0,
}) {
int patchSize = inChannels * kernelSize * kernelSize;
// Using fromList for initial weights (Xavier-like initialization)
final initialWeights = List.generate(outChannels * patchSize, (i) => 0.1);
weight = Tensor.fromList([outChannels, patchSize], initialWeights);
// Using fromList for bias [1, outChannels]
final initialBias = List.generate(outChannels, (i) => 0.0);
bias = Tensor.fromList([1, outChannels], initialBias);
}