Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#842 fixed version

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:bugfix/SG-000_fix_version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  1. import torch
  2. import torch.nn as nn
  3. import torch.nn.functional as F
  4. class AntiAliasDownsample(nn.Module):
  5. def __init__(self, in_channels: int, stride: int):
  6. super().__init__()
  7. self.kernel_size = 3
  8. self.stride = stride
  9. self.channels = in_channels
  10. a = torch.tensor([1.0, 2.0, 1.0])
  11. filt = a[:, None] * a[None, :]
  12. filt = filt / torch.sum(filt)
  13. self.register_buffer("filt", filt[None, None, :, :].repeat((self.channels, 1, 1, 1)))
  14. def forward(self, x):
  15. return F.conv2d(x, self.filt, stride=self.stride, padding=1, groups=self.channels)
Discard
Tip!

Press p or to see the previous file or, n or to see the next file