SwinEncoder constructor
SwinEncoder({})
Implementation
SwinEncoder({
required this.inputSize,
this.alignLongAxis = false,
this.windowSize = 10,
this.encoderLayer = const [2, 2, 14, 2],
this.embedDim = 128,
this.numHeads = const [4, 8, 16, 32],
this.patchSize = 4,
}) {
patchEmbed = PatchEmbed(
imgSize: inputSize,
patchSize: patchSize,
embedDim: embedDim,
);
patchH = inputSize[0] ~/ patchSize;
patchW = inputSize[1] ~/ patchSize;
posDropout = Dropout();
layers = [];
int currentDim = embedDim;
for (int i = 0; i < encoderLayer.length; i++) {
final isLast = i == encoderLayer.length - 1;
layers.add(SwinLayer(
dim: currentDim,
depth: encoderLayer[i],
numHeads: numHeads[i],
windowSize: windowSize,
downsample: !isLast,
));
if (!isLast) {
currentDim *= 2;
}
}
}