Browse Source

fix _self_tracked_trackables.

tags/v0.100.4-load-saved-model
Haiping Chen 2 years ago
parent
commit
4f88109ae3
8 changed files with 28 additions and 19 deletions
  1. +2
    -0
      src/TensorFlowNET.Core/Keras/IInitializersApi.cs
  2. +6
    -6
      src/TensorFlowNET.Core/Tensorflow.Binding.csproj
  3. +1
    -6
      src/TensorFlowNET.Keras/Engine/Functional.cs
  4. +3
    -1
      src/TensorFlowNET.Keras/Engine/Sequential.cs
  5. +1
    -1
      src/TensorFlowNET.Keras/InitializersApi.cs
  6. +5
    -0
      src/TensorFlowNET.Keras/Layers/Rnn/RNN.cs
  7. +6
    -1
      src/TensorFlowNET.Keras/Layers/Rnn/SimpleRNNCell.cs
  8. +4
    -4
      src/TensorFlowNET.Keras/Tensorflow.Keras.csproj

+ 2
- 0
src/TensorFlowNET.Core/Keras/IInitializersApi.cs View File

@@ -7,5 +7,7 @@ namespace Tensorflow.Keras
public interface IInitializersApi public interface IInitializersApi
{ {
IInitializer Orthogonal(float gain = 1.0f, int? seed = null); IInitializer Orthogonal(float gain = 1.0f, int? seed = null);

IInitializer HeNormal(int? seed = null);
} }
} }

+ 6
- 6
src/TensorFlowNET.Core/Tensorflow.Binding.csproj View File

@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Tensorflow.Binding</AssemblyName> <AssemblyName>Tensorflow.Binding</AssemblyName>
<RootNamespace>Tensorflow</RootNamespace> <RootNamespace>Tensorflow</RootNamespace>
<TargetTensorFlow>2.2.0</TargetTensorFlow>
<Version>0.100.0</Version>
<TargetTensorFlow>2.10.0</TargetTensorFlow>
<Version>0.100.1</Version>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors> <Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
@@ -20,7 +20,7 @@
<Description>Google's TensorFlow full binding in .NET Standard. <Description>Google's TensorFlow full binding in .NET Standard.
Building, training and infering deep learning models. Building, training and infering deep learning models.
https://tensorflownet.readthedocs.io</Description> https://tensorflownet.readthedocs.io</Description>
<AssemblyVersion>0.100.0.0</AssemblyVersion>
<AssemblyVersion>0.100.1.0</AssemblyVersion>
<PackageReleaseNotes> <PackageReleaseNotes>
tf.net 0.100.x and above are based on tensorflow native 2.10.0 tf.net 0.100.x and above are based on tensorflow native 2.10.0


@@ -38,7 +38,7 @@ https://tensorflownet.readthedocs.io</Description>
tf.net 0.7x.x aligns with TensorFlow v2.7.x native library. tf.net 0.7x.x aligns with TensorFlow v2.7.x native library.
tf.net 0.10x.x aligns with TensorFlow v2.10.x native library. tf.net 0.10x.x aligns with TensorFlow v2.10.x native library.
</PackageReleaseNotes> </PackageReleaseNotes>
<FileVersion>0.100.0.0</FileVersion>
<FileVersion>0.100.1.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
@@ -108,7 +108,7 @@ https://tensorflownet.readthedocs.io</Description>


<ItemGroup> <ItemGroup>
<PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.148" /> <PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.148" />
<PackageReference Include="Protobuf.Text" Version="0.5.0" />
<PackageReference Include="Protobuf.Text" Version="0.6.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 1
- 6
src/TensorFlowNET.Keras/Engine/Functional.cs View File

@@ -65,12 +65,7 @@ namespace Tensorflow.Keras.Engine
} }


// Keep track of the network's nodes and layers. // Keep track of the network's nodes and layers.
(NetworkNodes, NodesByDepth, var layers, _) = MapGraphNetwork(inputs, outputs);

if (!_self_tracked_trackables.Any())
{
_self_tracked_trackables = layers;
}
(NetworkNodes, NodesByDepth, _self_tracked_trackables, _) = MapGraphNetwork(inputs, outputs);


// Build self.input_names and self.output_names. // Build self.input_names and self.output_names.
_set_output_names(); _set_output_names();


+ 3
- 1
src/TensorFlowNET.Keras/Engine/Sequential.cs View File

@@ -110,6 +110,8 @@ namespace Tensorflow.Keras.Engine
} }
else if (outputs != null) else if (outputs != null)
{ {
// If the model is being built continuously on top of an input layer:
// refresh its output.
outputs = layer.Apply(outputs); outputs = layer.Apply(outputs);
built = true; built = true;
} }
@@ -155,7 +157,7 @@ namespace Tensorflow.Keras.Engine
Tensors layer_output = null; Tensors layer_output = null;
Tensors outputs = null; Tensors outputs = null;
List<INode> created_nodes = new List<INode>(); List<INode> created_nodes = new List<INode>();
foreach (var layer in _self_tracked_trackables)
foreach (var layer in args.Layers)
{ {
clear_previously_created_nodes(layer, _created_nodes); clear_previously_created_nodes(layer, _created_nodes);
layer_output = layer.Apply(layer_input); layer_output = layer.Apply(layer_input);


+ 1
- 1
src/TensorFlowNET.Keras/InitializersApi.cs View File

@@ -25,7 +25,7 @@ public partial class InitializersApi : IInitializersApi
/// </summary> /// </summary>
/// <param name="seed"></param> /// <param name="seed"></param>
/// <returns></returns> /// <returns></returns>
public IInitializer he_normal(int? seed = null)
public IInitializer HeNormal(int? seed = null)
{ {
return new VarianceScaling(factor: 2.0f, mode: "fan_in", seed: seed); return new VarianceScaling(factor: 2.0f, mode: "fan_in", seed: seed);
} }


+ 5
- 0
src/TensorFlowNET.Keras/Layers/Rnn/RNN.cs View File

@@ -45,6 +45,11 @@ namespace Tensorflow.Keras.Layers.Rnn
} }
} }


protected override Tensors Call(Tensors inputs, Tensor state = null, bool? training = null)
{
return base.Call(inputs, state, training);
}

private static RNNArgs PreConstruct(RNNArgs args) private static RNNArgs PreConstruct(RNNArgs args)
{ {
if (args.Kwargs == null) if (args.Kwargs == null)


+ 6
- 1
src/TensorFlowNET.Keras/Layers/Rnn/SimpleRNNCell.cs View File

@@ -33,11 +33,16 @@ namespace Tensorflow.Keras.Layers.Rnn
if (args.UseBias) if (args.UseBias)
{ {
bias = add_weight("bias", (args.Units), bias = add_weight("bias", (args.Units),
initializer: args.RecurrentInitializer
initializer: args.BiasInitializer
); );
} }


built = true; built = true;
} }

protected override Tensors Call(Tensors inputs, Tensor state = null, bool? training = null)
{
return base.Call(inputs, state, training);
}
} }
} }

+ 4
- 4
src/TensorFlowNET.Keras/Tensorflow.Keras.csproj View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">


<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<AssemblyName>Tensorflow.Keras</AssemblyName> <AssemblyName>Tensorflow.Keras</AssemblyName>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<RootNamespace>Tensorflow.Keras</RootNamespace> <RootNamespace>Tensorflow.Keras</RootNamespace>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<Version>0.10.0</Version>
<Version>0.10.1</Version>
<Authors>Haiping Chen</Authors> <Authors>Haiping Chen</Authors>
<Product>Keras for .NET</Product> <Product>Keras for .NET</Product>
<Copyright>Apache 2.0, Haiping Chen 2021</Copyright> <Copyright>Apache 2.0, Haiping Chen 2021</Copyright>
@@ -37,8 +37,8 @@ Keras is an API designed for human beings, not machines. Keras follows best prac
<RepositoryType>Git</RepositoryType> <RepositoryType>Git</RepositoryType>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>0.10.0.0</AssemblyVersion>
<FileVersion>0.10.0.0</FileVersion>
<AssemblyVersion>0.10.1.0</AssemblyVersion>
<FileVersion>0.10.1.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<Configurations>Debug;Release;GPU</Configurations> <Configurations>Debug;Release;GPU</Configurations>
</PropertyGroup> </PropertyGroup>


Loading…
Cancel
Save