Browse Source

got rid off the reference to the TF.NET

tags/v0.12
Kerry Jiang 6 years ago
parent
commit
6b9f86906f
4 changed files with 8 additions and 8 deletions
  1. +3
    -3
      src/TensorFlowHub/MnistDataSet.cs
  2. +3
    -3
      src/TensorFlowHub/MnistModelLoader.cs
  3. +1
    -1
      src/TensorFlowHub/ModelLoadSetting.cs
  4. +1
    -1
      src/TensorFlowHub/TensorFlowHub.csproj

+ 3
- 3
src/TensorFlowHub/MnistDataSet.cs View File

@@ -12,7 +12,7 @@ namespace Tensorflow.Hub
public int EpochsCompleted { get; private set; }
public int IndexInEpoch { get; private set; }

public MnistDataSet(NDArray images, NDArray labels, TF_DataType dtype, bool reshape)
public MnistDataSet(NDArray images, NDArray labels, Type dataType, bool reshape)
{
EpochsCompleted = 0;
IndexInEpoch = 0;
@@ -20,11 +20,11 @@ namespace Tensorflow.Hub
NumOfExamples = images.shape[0];

images = images.reshape(images.shape[0], images.shape[1] * images.shape[2]);
images.astype(dtype.as_numpy_datatype());
images.astype(dataType);
images = np.multiply(images, 1.0f / 255.0f);
Data = images;

labels.astype(dtype.as_numpy_datatype());
labels.astype(dataType);
Labels = labels;
}
}


+ 3
- 3
src/TensorFlowHub/MnistModelLoader.cs View File

@@ -81,7 +81,7 @@ namespace Tensorflow.Hub
trainImages = trainImages[np.arange(validationSize, end)];
trainLabels = trainLabels[np.arange(validationSize, end)];

var dtype = setting.DtType;
var dtype = setting.DataType;
var reshape = setting.ReShape;

var train = new MnistDataSet(trainImages, trainLabels, dtype, reshape);
@@ -100,7 +100,7 @@ namespace Tensorflow.Hub
{
var magic = Read32(bytestream);
if (magic != 2051)
throw new ValueError($"Invalid magic number {magic} in MNIST image file: {file}");
throw new Exception($"Invalid magic number {magic} in MNIST image file: {file}");
var num_images = Read32(bytestream);
num_images = limit == null ? num_images : Math.Min(num_images, (uint)limit);
@@ -128,7 +128,7 @@ namespace Tensorflow.Hub
{
var magic = Read32(bytestream);
if (magic != 2049)
throw new ValueError($"Invalid magic number {magic} in MNIST label file: {file}");
throw new Exception($"Invalid magic number {magic} in MNIST label file: {file}");
var num_items = Read32(bytestream);
num_items = limit == null ? num_items : Math.Min(num_items, (uint)limit);


+ 1
- 1
src/TensorFlowHub/ModelLoadSetting.cs View File

@@ -9,7 +9,7 @@ namespace Tensorflow.Hub
{
public string TrainDir { get; set; }
public bool OneHot { get; set; }
public TF_DataType DtType { get; set; } = TF_DataType.TF_FLOAT;
public Type DataType { get; set; } = typeof(float);
public bool ReShape { get; set; }
public int ValidationSize { get; set; } = 5000;
public int? TrainSize { get; set; }


+ 1
- 1
src/TensorFlowHub/TensorFlowHub.csproj View File

@@ -4,6 +4,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
<PackageReference Include="NumSharp" Version="0.10.6" />
</ItemGroup>
</Project>

Loading…
Cancel
Save