added activation for features
This commit is contained in:
+8
-3
@@ -146,6 +146,8 @@ class ConvNeXtBase(nn.Module):
|
|||||||
).to(device)
|
).to(device)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.act = nn.Tanh()
|
||||||
|
|
||||||
for m in self.modules():
|
for m in self.modules():
|
||||||
if isinstance(m, (nn.Conv2d, nn.Linear)):
|
if isinstance(m, (nn.Conv2d, nn.Linear)):
|
||||||
nn.init.trunc_normal_(m.weight, std=0.02)
|
nn.init.trunc_normal_(m.weight, std=0.02)
|
||||||
@@ -160,7 +162,7 @@ class ConvNeXtBase(nn.Module):
|
|||||||
features.append(x)
|
features.append(x)
|
||||||
x = self.downsamples[i](x)
|
x = self.downsamples[i](x)
|
||||||
x = self.stages[-1](x)
|
x = self.stages[-1](x)
|
||||||
|
x = self.act(x)
|
||||||
|
|
||||||
return x, features
|
return x, features
|
||||||
|
|
||||||
@@ -242,8 +244,11 @@ class ConvNeXtReverseBase2(nn.Module):
|
|||||||
kernel_size=7,
|
kernel_size=7,
|
||||||
padding=3,
|
padding=3,
|
||||||
).to(device)
|
).to(device)
|
||||||
|
# self.last = nn.Sequential(
|
||||||
# Dense?
|
# Permute([0, 2, 3, 1]),
|
||||||
|
# nn.Linear(in_features=block_setting[-1].input_channels, out_features=1, bias=True),
|
||||||
|
# Permute([0, 3, 1, 2]),
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
for m in self.modules():
|
for m in self.modules():
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ class DepthEstimation(nn.Module):
|
|||||||
CNBlockConfig(9, None, 3),
|
CNBlockConfig(9, None, 3),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.convnext = ConvNeXt(block_setting)
|
self.convnext = ConvNeXt(block_setting, device=device)
|
||||||
self.flatten = nn.Flatten()
|
self.flatten = nn.Flatten()
|
||||||
self.decoder = ConvNeXt(block_setting_reverse, reversed=True)
|
self.decoder = ConvNeXt(block_setting_reverse, reversed=True, device=device)
|
||||||
|
|
||||||
|
|
||||||
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ if __name__ == '__main__':
|
|||||||
train_accumulator = Accumulator()
|
train_accumulator = Accumulator()
|
||||||
valid_accumulator = Accumulator()
|
valid_accumulator = Accumulator()
|
||||||
|
|
||||||
model = DepthEstimation().to('cuda')
|
model = DepthEstimation(device=device)
|
||||||
|
|
||||||
loss_fn = nn.MSELoss()
|
loss_fn = nn.MSELoss()
|
||||||
optimizer = optim.Adam(model.parameters(), lr=0.001)
|
optimizer = optim.Adam(model.parameters(), lr=0.001)
|
||||||
|
|||||||
Reference in New Issue
Block a user