| AFF |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("349e038d05b2cfce") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 5, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
class GatedConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d):
super().__init__()
self.pad_mode = padding_mode
self.filter_size = kernel_size
self.stride = stride
self.dilation = dilation
n_pad_pxl = int(self.dilation * (self.filter_size - 1) / 2)
self.flag = relu
self.block = nn.ModuleDict({'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_f': act_fun(), 'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_m': nn.Sigmoid(), 'norm': normalization(out_channels)})
def forward(self, x, *args, **kwargs):
if self.flag:
features = self.block.act_f(self.block.conv_f(x))
else:
features = self.block.conv_f(x)
mask = self.block.act_m(self.block.conv_m(x))
output = features * mask
output = self.block.norm(output)
return output
class AFF(nn.Module):
def __init__(self, in_channel, out_channel):
super(AFF, self).__init__()
self.conv = nn.Sequential(GatedConv(in_channel, out_channel, kernel_size=1, stride=1, relu=True), GatedConv(out_channel, out_channel, kernel_size=3, stride=1, relu=False))
def forward(self, x1, x2, x3, x4):
x = torch.cat([x1, x2, x3, x4], dim=1)
return self.conv(x)
INIT_ARGS = {
'in_channel': 8,
'out_channel': 4,
}
ARGS = {
'x1': torch.randn(2, 2, 5, 6),
'x2': torch.randn(2, 2, 5, 6),
'x3': torch.randn(2, 2, 5, 6),
'x4': torch.randn(2, 2, 5, 6),
}
if __name__ == '__main__':
model = AFF(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Output: {output}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 5, 6) — shape (2, 4, 5, 6) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| DBlock |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("14e81d2a2db05c54") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
# Import the classes
class GatedConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d):
super().__init__()
self.pad_mode = padding_mode
self.filter_size = kernel_size
self.stride = stride
self.dilation = dilation
n_pad_pxl = int(self.dilation * (self.filter_size - 1) / 2)
self.flag = relu
self.block = nn.ModuleDict({'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_f': act_fun(), 'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_m': nn.Sigmoid(), 'norm': normalization(out_channels)})
def forward(self, x, *args, **kwargs):
if self.flag:
features = self.block.act_f(self.block.conv_f(x))
else:
features = self.block.conv_f(x)
mask = self.block.act_m(self.block.conv_m(x))
output = features * mask
output = self.block.norm(output)
return output
class ResBlock(nn.Module):
def __init__(self, in_channel, out_channel):
super(ResBlock, self).__init__()
self.main = nn.Sequential(GatedConv(in_channel, out_channel, kernel_size=3, stride=1, relu=True), GatedConv(out_channel, out_channel, kernel_size=3, stride=1, relu=False))
def forward(self, x):
return self.main(x) + x
class DBlock(nn.Module):
def __init__(self, channel, num_res=8):
super(DBlock, self).__init__()
layers = [ResBlock(channel, channel) for _ in range(num_res)]
self.layers = nn.Sequential(*layers)
def forward(self, x):
return self.layers(x)
INIT_ARGS = {
'channel': 4,
'num_res': 2
}
ARGS = {
'x': torch.randn(2, 4, 3, 3)
}
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 3, 3) — shape (2, 4, 3, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| EBlock |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("5642600dfdadb227") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
# Construct the class
INIT_ARGS = {
'out_channel': 4,
'num_res': 2
}
# Arguments for forward pass
ARGS = {
'x': torch.randn(2, 4, 8, 8)
}
# Instantiate and call
instance = nn.Module()
instance.__class__ = type('EBlock', (nn.Module,), {
'__init__': lambda self, out_channel, num_res=8: (
super(type(self), self).__init__(),
setattr(self, 'layers', nn.Sequential(*[
type('ResBlock', (nn.Module,), {
'__init__': lambda s, in_ch, out_ch: (
super(type(s), s).__init__(),
setattr(s, 'main', nn.Sequential(
type('GatedConv', (nn.Module,), {
'__init__': lambda g, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d: (
super(type(g), g).__init__(),
setattr(g, 'pad_mode', padding_mode),
setattr(g, 'filter_size', kernel_size),
setattr(g, 'stride', stride),
setattr(g, 'dilation', dilation),
setattr(g, 'flag', relu),
setattr(g, 'block', nn.ModuleDict({
'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=int(dilation * (kernel_size - 1) / 2)),
'act_f': act_fun(),
'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=int(dilation * (kernel_size - 1) / 2)),
'act_m': nn.Sigmoid(),
'norm': normalization(out_channels)
}))
),
'forward': lambda g, x, *args, **kwargs: (
g.block.norm(
(g.block.act_f(g.block.conv_f(x)) if g.flag else g.block.conv_f(x)) * g.block.act_m(g.block.conv_m(x))
)
)
})(in_ch, out_ch),
type('GatedConv', (nn.Module,), {
'__init__': lambda g, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d: (
super(type(g), g).__init__(),
setattr(g, 'pad_mode', padding_mode),
setattr(g, 'filter_size', kernel_size),
setattr(g, 'stride', stride),
setattr(g, 'dilation', dilation),
setattr(g, 'flag', relu),
setattr(g, 'block', nn.ModuleDict({
'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=int(dilation * (kernel_size - 1) / 2)),
'act_f': act_fun(),
'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=int(dilation * (kernel_size - 1) / 2)),
'act_m': nn.Sigmoid(),
'norm': normalization(out_channels)
}))
),
'forward': lambda g, x, *args, **kwargs: (
g.block.norm(
(g.block.act_f(g.block.conv_f(x)) if g.flag else g.block.conv_f(x)) * g.block.act_m(g.block.conv_m(x))
)
)
})(out_ch, out_ch)
))
),
'forward': lambda s, x: s.main(x) + x
})(out_channel, out_channel)
for _ in range(num_res)
]))
),
'forward': lambda self, x: self.layers(x)
})
# Simpler approach - just define the classes directly
class GatedConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d):
super().__init__()
self.pad_mode = padding_mode
self.filter_size = kernel_size
self.stride = stride
self.dilation = dilation
n_pad_pxl = int(self.dilation * (self.filter_size - 1) / 2)
self.flag = relu
self.block = nn.ModuleDict({'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_f': act_fun(), 'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_m': nn.Sigmoid(), 'norm': normalization(out_channels)})
def forward(self, x, *args, **kwargs):
if self.flag:
features = self.block.act_f(self.block.conv_f(x))
else:
features = self.block.conv_f(x)
mask = self.block.act_m(self.block.conv_m(x))
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) — shape (2, 4, 8, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| FAM |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("4eb9ea5b3e878e63") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 8, 6) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
class GatedConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d):
super().__init__()
self.pad_mode = padding_mode
self.filter_size = kernel_size
self.stride = stride
self.dilation = dilation
n_pad_pxl = int(self.dilation * (self.filter_size - 1) / 2)
self.flag = relu
self.block = nn.ModuleDict({'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_f': act_fun(), 'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_m': nn.Sigmoid(), 'norm': normalization(out_channels)})
def forward(self, x, *args, **kwargs):
if self.flag:
features = self.block.act_f(self.block.conv_f(x))
else:
features = self.block.conv_f(x)
mask = self.block.act_m(self.block.conv_m(x))
output = features * mask
output = self.block.norm(output)
return output
class FAM(nn.Module):
def __init__(self, channel):
super(FAM, self).__init__()
self.merge = GatedConv(channel, channel, kernel_size=3, stride=1, relu=False)
def forward(self, x1, x2):
x = x1 * x2
out = x1 + self.merge(x)
return out
INIT_ARGS = {
'channel': 4
}
ARGS = {
'x1': torch.randn(2, 4, 8, 6),
'x2': torch.randn(2, 4, 8, 6)
}
if __name__ == '__main__':
model = FAM(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: {ARGS['x1'].shape}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 8, 6) — shape (2, 4, 8, 6) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| FourierUnit |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("60e29924690d6157") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
INIT_ARGS = {
'in_channels': 4,
'out_channels': 8,
'groups': 1,
'spatial_scale_factor': None,
'spatial_scale_mode': 'bilinear',
'spectral_pos_encoding': False,
'ffc3d': False,
'fft_norm': 'ortho'
}
ARGS = {
'x': torch.randn(2, 4, 6, 5)
}
if __name__ == '__main__':
import torch.nn as nn
import torch.nn.functional as F
class FourierUnit(nn.Module):
def __init__(self, in_channels, out_channels, groups=1, spatial_scale_factor=None, spatial_scale_mode='bilinear', spectral_pos_encoding=False, ffc3d=False, fft_norm='ortho'):
super(FourierUnit, self).__init__()
self.groups = groups
self.conv_layer = torch.nn.Conv2d(in_channels=in_channels * 2 + (2 if spectral_pos_encoding else 0), out_channels=out_channels * 2, kernel_size=1, stride=1, padding=0, groups=self.groups, bias=False)
self.bn = torch.nn.BatchNorm2d(out_channels * 2)
self.relu = torch.nn.ReLU(inplace=True)
self.spatial_scale_factor = spatial_scale_factor
self.spatial_scale_mode = spatial_scale_mode
self.spectral_pos_encoding = spectral_pos_encoding
self.ffc3d = ffc3d
self.fft_norm = fft_norm
def forward(self, x):
batch = x.shape[0]
if self.spatial_scale_factor is not None:
orig_size = x.shape[-2:]
x = F.interpolate(x, scale_factor=self.spatial_scale_factor, mode=self.spatial_scale_mode, align_corners=False)
r_size = x.size()
fft_dim = (-3, -2, -1) if self.ffc3d else (-2, -1)
ffted = torch.fft.rfftn(x, dim=fft_dim, norm=self.fft_norm)
ffted = torch.stack((ffted.real, ffted.imag), dim=-1)
ffted = ffted.permute(0, 1, 4, 2, 3).contiguous()
ffted = ffted.view((batch, -1) + ffted.size()[3:])
if self.spectral_pos_encoding:
height, width = ffted.shape[-2:]
coords_vert = torch.linspace(0, 1, height)[None, None, :, None].expand(batch, 1, height, width).to(ffted)
coords_hor = torch.linspace(0, 1, width)[None, None, None, :].expand(batch, 1, height, width).to(ffted)
ffted = torch.cat((coords_vert, coords_hor, ffted), dim=1)
ffted = self.conv_layer(ffted)
ffted = self.relu(self.bn(ffted))
ffted = ffted.view((batch, -1, 2) + ffted.size()[2:]).permute(0, 1, 3, 4, 2).contiguous()
ffted = torch.complex(ffted[..., 0], ffted[..., 1])
ifft_shape_slice = x.shape[-3:] if self.ffc3d else x.shape[-2:]
output = torch.fft.irfftn(ffted, s=ifft_shape_slice, dim=fft_dim, norm=self.fft_norm)
if self.spatial_scale_factor is not None:
output = F.interpolate(output, size=orig_size, mode=self.spatial_scale_mode, align_corners=False)
return output
module = FourierUnit(**INIT_ARGS)
output = module(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: {ARGS['x'].shape}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| GatedConv |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("24b0cd7a503871f5") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
INIT_ARGS = {
'in_channels': 3,
'out_channels': 4,
'kernel_size': 3,
'stride': 1,
'relu': True,
'dilation': 1,
'padding_mode': 'reflect',
'act_fun': nn.ELU,
'normalization': nn.BatchNorm2d,
}
ARGS = {
'x': torch.randn(2, 3, 8, 8),
}
if __name__ == '__main__':
from torch.nn import GatedConv
model = GatedConv(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 4, 8, 8)")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) — shape (2, 4, 8, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| ResBlock |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("28239e93e175637f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
INIT_ARGS = {
'in_channel': 4,
'out_channel': 4,
}
ARGS = {
'x': torch.randn(2, 4, 8, 8),
}
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 4, 8, 8) — shape (2, 4, 8, 8) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| SCM |
Ran ran on a synthesized input |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("2b1106c990cc59b9") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 4, dtype family float, shape (2, 32, 4, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
class GatedConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, relu=True, dilation=1, padding_mode='reflect', act_fun=nn.ELU, normalization=nn.BatchNorm2d):
super().__init__()
self.pad_mode = padding_mode
self.filter_size = kernel_size
self.stride = stride
self.dilation = dilation
n_pad_pxl = int(self.dilation * (self.filter_size - 1) / 2)
self.flag = relu
self.block = nn.ModuleDict({'conv_f': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_f': act_fun(), 'conv_m': nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, dilation=dilation, padding=n_pad_pxl), 'act_m': nn.Sigmoid(), 'norm': normalization(out_channels)})
def forward(self, x, *args, **kwargs):
if self.flag:
features = self.block.act_f(self.block.conv_f(x))
else:
features = self.block.conv_f(x)
mask = self.block.act_m(self.block.conv_m(x))
output = features * mask
output = self.block.norm(output)
return output
class SCM(nn.Module):
def __init__(self, out_plane):
super(SCM, self).__init__()
self.main = nn.Sequential(GatedConv(8, out_plane // 4, kernel_size=3, stride=1, relu=True), GatedConv(out_plane // 4, out_plane // 2, kernel_size=1, stride=1, relu=True), GatedConv(out_plane // 2, out_plane // 2, kernel_size=3, stride=1, relu=True), GatedConv(out_plane // 2, out_plane - 8, kernel_size=1, stride=1, relu=True))
self.conv = GatedConv(out_plane, out_plane, kernel_size=1, stride=1, relu=False)
def forward(self, x):
x = torch.cat([x, self.main(x)], dim=1)
return self.conv(x)
INIT_ARGS = {
'out_plane': 32
}
ARGS = {
'x': torch.randn(2, 8, 4, 3)
}
if __name__ == '__main__':
model = SCM(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Output dtype: {output.dtype}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Tensor, ndim 4, dtype family float, shape (2, 32, 4, 3) — shape (2, 32, 4, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| FFC |
Not yet run unverified (harvested, no recorded run) |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("dde97bb42a868625") How it ran |
| FFCResnetBlock |
Not yet run unverified (harvested, no recorded run) |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("b1336d91e7c827d8") How it ran |
| FFC_BN_ACT |
Not yet run unverified (harvested, no recorded run) |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("1fdc8eec4ba8e86d") How it ran |
| MIMOUNet |
Not yet run unverified (harvested, no recorded run) |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("778754a205589fec") How it ran |
| SpectralTransform |
Not yet run unverified (harvested, no recorded run) |
QT-Zhu/RPBG/RPBG/models/mimounet.py code served (permissive licence) · get_code("65bcb1a744d547fe") How it ran |