Skip to content

Commit ded0325

Browse files
committed
Change to NumSharp compact version.
1 parent 121736f commit ded0325

5 files changed

Lines changed: 12 additions & 44 deletions

File tree

src/TensorFlowNET.Core/Operations/random_ops.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static Tensor random_uniform(int[] shape,
8080
}
8181

8282
public static Tensor random_uniform(Tensor shape,
83-
long minval = 0,
83+
int minval = 0,
8484
Tensor maxval = null,
8585
TF_DataType dtype = TF_DataType.TF_FLOAT,
8686
int? seed = null,

src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,51 +58,18 @@ public override NDArray[] build_results(List<NDArray> values)
5858
case NDArray value:
5959
result = new[] { value };
6060
break;
61-
#if _REGEN
62-
%types=["sbyte", "bool", "byte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "Complex"]
63-
%foreach types%
64-
case #1 value:
65-
result = new[] { NDArray.Scalar(value) };
66-
break;
67-
%
68-
#else
69-
case sbyte value:
70-
result = new[] { NDArray.Scalar(value) };
71-
break;
7261
case bool value:
7362
result = new[] { NDArray.Scalar(value) };
7463
break;
7564
case byte value:
7665
result = new[] { NDArray.Scalar(value) };
7766
break;
78-
case short value:
79-
result = new[] { NDArray.Scalar(value) };
80-
break;
81-
case ushort value:
82-
result = new[] { NDArray.Scalar(value) };
83-
break;
8467
case int value:
8568
result = new[] { NDArray.Scalar(value) };
8669
break;
87-
case uint value:
88-
result = new[] { NDArray.Scalar(value) };
89-
break;
90-
case long value:
91-
result = new[] { NDArray.Scalar(value) };
92-
break;
93-
case ulong value:
94-
result = new[] { NDArray.Scalar(value) };
95-
break;
9670
case float value:
9771
result = new[] { NDArray.Scalar(value) };
9872
break;
99-
case double value:
100-
result = new[] { NDArray.Scalar(value) };
101-
break;
102-
case Complex value:
103-
result = new[] { NDArray.Scalar(value) };
104-
break;
105-
#endif
10673
default:
10774
break;
10875
}

src/TensorFlowNET.Core/TensorFlow.Binding.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ https://tensorflownet.readthedocs.io</Description>
6060

6161
<ItemGroup>
6262
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
63-
<PackageReference Include="NumSharp" Version="0.20.5" />
63+
<PackageReference Include="NumSharp" Version="0.30.0-alpha" />
6464
</ItemGroup>
6565

6666
<ItemGroup>

src/TensorFlowNET.Hub/MnistModelLoader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private NDArray ExtractImages(string file, int? limit = null)
116116
throw new Exception($"Invalid magic number {magic} in MNIST image file: {file}");
117117

118118
var num_images = Read32(bytestream);
119-
num_images = limit == null ? num_images : Math.Min(num_images, (uint)limit);
119+
num_images = limit == null ? num_images : Math.Min(num_images, (int)limit);
120120

121121
var rows = Read32(bytestream);
122122
var cols = Read32(bytestream);
@@ -125,8 +125,8 @@ private NDArray ExtractImages(string file, int? limit = null)
125125

126126
bytestream.Read(buf, 0, buf.Length);
127127

128-
var data = np.frombuffer(buf, np.uint8);
129-
data = data.reshape((int)num_images, (int)rows, (int)cols, 1);
128+
var data = np.frombuffer(buf, np.@byte);
129+
data = data.reshape(num_images, rows, cols, 1);
130130

131131
return data;
132132
}
@@ -144,7 +144,7 @@ private NDArray ExtractLabels(string file, bool one_hot = false, int num_classes
144144
throw new Exception($"Invalid magic number {magic} in MNIST label file: {file}");
145145

146146
var num_items = Read32(bytestream);
147-
num_items = limit == null ? num_items : Math.Min(num_items, (uint)limit);
147+
num_items = limit == null ? num_items : Math.Min(num_items, (int)limit);
148148

149149
var buf = new byte[num_items];
150150

@@ -174,11 +174,11 @@ private NDArray DenseToOneHot(NDArray labels_dense, int num_classes)
174174
return labels_one_hot;
175175
}
176176

177-
private uint Read32(FileStream bytestream)
177+
private int Read32(FileStream bytestream)
178178
{
179179
var buffer = new byte[sizeof(uint)];
180180
var count = bytestream.Read(buffer, 0, 4);
181-
return np.frombuffer(buffer, ">u4").Data<uint>()[0];
181+
return np.frombuffer(buffer, ">u4").Data<int>()[0];
182182
}
183183
}
184184
}

src/TensorFlowNET.Hub/Tensorflow.Hub.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<RootNamespace>Tensorflow.Hub</RootNamespace>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>0.0.5</Version>
5+
<Version>0.0.6</Version>
66
<Authors>Kerry Jiang, Haiping Chen</Authors>
77
<Company>SciSharp STACK</Company>
88
<Copyright>Apache 2.0</Copyright>
@@ -13,14 +13,15 @@
1313
<Description>TensorFlow Hub is a library to foster the publication, discovery, and consumption of reusable parts of machine learning models.</Description>
1414
<PackageId>SciSharp.TensorFlowHub</PackageId>
1515
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
16-
<PackageReleaseNotes>Fix GetNextBatch() bug.</PackageReleaseNotes>
16+
<PackageReleaseNotes>Fix GetNextBatch() bug.
17+
Change to NumSharp compact version.</PackageReleaseNotes>
1718
<PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&amp;v=4</PackageIconUrl>
1819
<AssemblyName>TensorFlow.Hub</AssemblyName>
1920
</PropertyGroup>
2021
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2122
<DefineConstants>DEBUG;TRACE</DefineConstants>
2223
</PropertyGroup>
2324
<ItemGroup>
24-
<PackageReference Include="NumSharp" Version="0.20.5" />
25+
<PackageReference Include="NumSharp" Version="0.30.0-alpha" />
2526
</ItemGroup>
2627
</Project>

0 commit comments

Comments
 (0)