Skip to content

Commit

Permalink
Updated to latest torchsharp version
Browse files Browse the repository at this point in the history
  • Loading branch information
ncguilbeault committed Jan 21, 2025
1 parent 30299e1 commit 7f693a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Bonsai.ML.Torch/Bonsai.ML.Torch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OpenCV.Net" Version="3.4.2" />
<PackageReference Include="TorchSharp" Version="0.103.1" />
<PackageReference Include="TorchVision" Version="0.103.1" />
<PackageReference Include="TorchSharp" Version="0.105.0" />
<PackageReference Include="TorchVision" Version="0.105.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bonsai.ML\Bonsai.ML.csproj" />
Expand Down
16 changes: 8 additions & 8 deletions src/Bonsai.ML.Torch/NeuralNets/Models/AlexNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public class AlexNet : Module<Tensor, Tensor>
public AlexNet(string name, int numClasses, Device device = null) : base(name)
{
features = Sequential(
("c1", Conv2d(3, 64, kernelSize: 3, stride: 2, padding: 1)),
("c1", Conv2d(3, 64, kernel_size: 3, stride: 2, padding: 1)),
("r1", ReLU(inplace: true)),
("mp1", MaxPool2d(kernelSize: [ 2, 2 ])),
("c2", Conv2d(64, 192, kernelSize: 3, padding: 1)),
("mp1", MaxPool2d(kernel_size: [ 2, 2 ])),
("c2", Conv2d(64, 192, kernel_size: 3, padding: 1)),
("r2", ReLU(inplace: true)),
("mp2", MaxPool2d(kernelSize: [ 2, 2 ])),
("c3", Conv2d(192, 384, kernelSize: 3, padding: 1)),
("mp2", MaxPool2d(kernel_size: [ 2, 2 ])),
("c3", Conv2d(192, 384, kernel_size: 3, padding: 1)),
("r3", ReLU(inplace: true)),
("c4", Conv2d(384, 256, kernelSize: 3, padding: 1)),
("c4", Conv2d(384, 256, kernel_size: 3, padding: 1)),
("r4", ReLU(inplace: true)),
("c5", Conv2d(256, 256, kernelSize: 3, padding: 1)),
("c5", Conv2d(256, 256, kernel_size: 3, padding: 1)),
("r5", ReLU(inplace: true)),
("mp3", MaxPool2d(kernelSize: [ 2, 2 ])));
("mp3", MaxPool2d(kernel_size: [ 2, 2 ])));

avgPool = AdaptiveAvgPool2d([ 2, 2 ]);

Expand Down
2 changes: 1 addition & 1 deletion src/Bonsai.ML.Torch/NeuralNets/Models/MNIST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MNIST : Module<Tensor,Tensor>
private readonly Module<Tensor, Tensor> fc1 = Linear(9216, 128);
private readonly Module<Tensor, Tensor> fc2 = Linear(128, 128);

private readonly Module<Tensor, Tensor> pool1 = MaxPool2d(kernelSize: [2, 2]);
private readonly Module<Tensor, Tensor> pool1 = MaxPool2d(kernel_size: [2, 2]);

private readonly Module<Tensor, Tensor> relu1 = ReLU();
private readonly Module<Tensor, Tensor> relu2 = ReLU();
Expand Down
6 changes: 3 additions & 3 deletions src/Bonsai.ML.Torch/NeuralNets/Models/MobileNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MobileNet(string name, int numClasses, Device device = null) : base(name)

var modules = new List<(string, Module<Tensor, Tensor>)>
{
($"conv2d-first", Conv2d(3, 32, kernelSize: 3, stride: 1, padding: 1, bias: false)),
($"conv2d-first", Conv2d(3, 32, kernel_size: 3, stride: 1, padding: 1, bias: false)),
($"bnrm2d-first", BatchNorm2d(32)),
($"relu-first", ReLU())
};
Expand All @@ -53,10 +53,10 @@ private void MakeLayers(List<(string, Module<Tensor, Tensor>)> modules, long in_
var out_planes = planes[i];
var stride = strides[i];

modules.Add(($"conv2d-{i}a", Conv2d(in_planes, in_planes, kernelSize: 3, stride: stride, padding: 1, groups: in_planes, bias: false)));
modules.Add(($"conv2d-{i}a", Conv2d(in_planes, in_planes, kernel_size: 3, stride: stride, padding: 1, groups: in_planes, bias: false)));
modules.Add(($"bnrm2d-{i}a", BatchNorm2d(in_planes)));
modules.Add(($"relu-{i}a", ReLU()));
modules.Add(($"conv2d-{i}b", Conv2d(in_planes, out_planes, kernelSize: 1L, stride: 1L, padding: 0L, bias: false)));
modules.Add(($"conv2d-{i}b", Conv2d(in_planes, out_planes, kernel_size: 1L, stride: 1L, padding: 0L, bias: false)));
modules.Add(($"bnrm2d-{i}b", BatchNorm2d(out_planes)));
modules.Add(($"relu-{i}b", ReLU()));

Expand Down

0 comments on commit 7f693a5

Please sign in to comment.