Browse Source

fix tf.batch_matmul #755

tags/v0.40-tf2.4-tstring
Oceania2018 4 years ago
parent
commit
a942564fc9
6 changed files with 17 additions and 18 deletions
  1. +5
    -4
      README.md
  2. +1
    -0
      src/TensorFlowNET.Console/Tensorflow.Console.csproj
  3. +2
    -2
      src/TensorFlowNET.Core/APIs/tf.linalg.cs
  4. +3
    -8
      src/TensorFlowNET.Core/Operations/math_ops.cs
  5. +5
    -4
      src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
  6. +1
    -0
      src/TensorFlowNet.Benchmarks/Tensorflow.Benchmark.csproj

+ 5
- 4
README.md View File

@@ -9,7 +9,7 @@
[![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/en_US)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/javiercp/BinderTF.NET/master?urlpath=lab)

*master branch is based on tensorflow 2.3 now, v0.15-tensorflow1.15 is from tensorflow1.15.*
*master branch is based on tensorflow v2.4, v0.3x branch is based on tensorflow v2.3, v0.15-tensorflow1.15 is from tensorflow1.15.*


![tensors_flowing](docs/assets/tensors_flowing.gif)
@@ -30,7 +30,8 @@ Go through the online docs [TensorFlow for .NET](https://scisharp.github.io/tens

| TensorFlow | tf native1.14, cuda 10.0 | tf native 1.15, cuda 10.0 | tf native 2.3, cuda 10.1 | tf native 2.4, cuda 11 |
| -------------------------- | ------------- | -------------- | ------------- | ------------- |
| tf.net 0.3x, tf.keras 0.2 | | | x | not compatible |
| tf.net 0.4x, tf.keras 0.5 | | | | x |
| tf.net 0.3x, tf.keras 0.4 | | | x | |
| tf.net 0.2x | | x | x | |
| tf.net 0.15 | x | x | | |
| tf.net 0.14 | x | | | |
@@ -50,10 +51,10 @@ PM> Install-Package TensorFlow.Keras

### Install tensorflow binary
### For CPU version
PM> Install-Package SciSharp.TensorFlow.Redist -Version 2.3.1
PM> Install-Package SciSharp.TensorFlow.Redist

### For GPU version (CUDA and cuDNN are required)
PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU -Version 2.3.1
PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU
```

Import TF.NET and Keras API in your project.


+ 1
- 0
src/TensorFlowNET.Console/Tensorflow.Console.csproj View File

@@ -11,6 +11,7 @@

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>


+ 2
- 2
src/TensorFlowNET.Core/APIs/tf.linalg.cs View File

@@ -39,7 +39,7 @@ namespace Tensorflow
=> math_ops.matmul(a, b);

public Tensor batch_matmul(Tensor x, Tensor y, bool adj_x = false, bool adj_y = false, string name = null)
=> tf.Context.ExecuteOp("BatchMatMul", name, new ExecuteOpArgs(x, y).SetAttributes(new { adj_x, adj_y }));
=> math_ops.batch_matmul(x, y, adj_x: adj_x, adj_y: adj_y, name: name);
}

public Tensor diag(Tensor diagonal, string name = null)
@@ -74,6 +74,6 @@ namespace Tensorflow
/// <param name="name"></param>
/// <returns></returns>
public Tensor batch_matmul(Tensor x, Tensor y, bool adj_x = false, bool adj_y = false, string name = null)
=> tf.Context.ExecuteOp("BatchMatMul", name, new ExecuteOpArgs(x, y).SetAttributes(new { adj_x, adj_y }));
=> math_ops.batch_matmul(x, y, adj_x: adj_x, adj_y: adj_y, name: name);
}
}

+ 3
- 8
src/TensorFlowNET.Core/Operations/math_ops.cs View File

@@ -796,22 +796,17 @@ namespace Tensorflow
public static Tensor batch_matmul(Tensor x, Tensor y,
bool adj_x = false, bool adj_y = false,
string name = null)
{
Tensor result = null;

tf_with(ops.name_scope(name, "MatMul", new Tensor[] { x, y }), scope =>
=> tf_with(ops.name_scope(name, "MatMul", new Tensor[] { x, y }), scope =>
{
name = scope;

x = ops.convert_to_tensor(x, name: "a");
y = ops.convert_to_tensor(y, name: "b");

result = math_ops.batch_matmul(x, y, adj_x, adj_y, name);
return tf.Context.ExecuteOp("BatchMatMul", name, new ExecuteOpArgs(x, y)
.SetAttributes(new { adj_x, adj_y }));
});

return result;
}

/// <summary>
/// Returns the complex conjugate of a complex number.
/// </summary>


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

@@ -6,7 +6,7 @@
<LangVersion>8.0</LangVersion>
<RootNamespace>Tensorflow.Keras</RootNamespace>
<Platforms>AnyCPU;x64</Platforms>
<Version>0.4.1</Version>
<Version>0.5.0</Version>
<Authors>Haiping Chen</Authors>
<Product>Keras for .NET</Product>
<Copyright>Apache 2.0, Haiping Chen 2020</Copyright>
@@ -23,7 +23,8 @@
* Implemented backward_function.
* Support model.load_weights.
* Add Subtract layer
* Support YOLOv3 model.</PackageReleaseNotes>
* Support YOLOv3 model.
* Text preprocessing</PackageReleaseNotes>
<Description>Keras for .NET

Keras is an API designed for human beings, not machines. Keras follows best practices for reducing cognitive load: it offers consistent &amp; simple APIs, it minimizes the number of user actions required for common use cases, and it provides clear &amp; actionable error messages.</Description>
@@ -34,8 +35,8 @@ Keras is an API designed for human beings, not machines. Keras follows best prac
<RepositoryType>Git</RepositoryType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>0.4.1.0</AssemblyVersion>
<FileVersion>0.4.1.0</FileVersion>
<AssemblyVersion>0.5.0.0</AssemblyVersion>
<FileVersion>0.5.0.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>



+ 1
- 0
src/TensorFlowNet.Benchmarks/Tensorflow.Benchmark.csproj View File

@@ -9,6 +9,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">


Loading…
Cancel
Save