Add a tolorance to equivalence of NDArray.pull/1047/head
| @@ -33,7 +33,16 @@ namespace Tensorflow.NumPy | |||||
| return Scalar(false); | return Scalar(false); | ||||
| if(rhs is null) | if(rhs is null) | ||||
| return Scalar(false); | return Scalar(false); | ||||
| return new NDArray(math_ops.equal(lhs, rhs)); | |||||
| // TODO(Rinne): use np.allclose instead. | |||||
| if (lhs.dtype.is_floating() || rhs.dtype.is_floating()) | |||||
| { | |||||
| var diff = tf.abs(lhs - rhs); | |||||
| return new NDArray(gen_math_ops.less(diff, new NDArray(1e-5).astype(diff.dtype))); | |||||
| } | |||||
| else | |||||
| { | |||||
| return new NDArray(math_ops.equal(lhs, rhs)); | |||||
| } | |||||
| } | } | ||||
| [AutoNumPy] | [AutoNumPy] | ||||
| public static NDArray operator !=(NDArray lhs, NDArray rhs) | public static NDArray operator !=(NDArray lhs, NDArray rhs) | ||||
| @@ -42,7 +51,15 @@ namespace Tensorflow.NumPy | |||||
| return Scalar(false); | return Scalar(false); | ||||
| if(lhs is null || rhs is null) | if(lhs is null || rhs is null) | ||||
| return Scalar(true); | return Scalar(true); | ||||
| return new NDArray(math_ops.not_equal(lhs, rhs)); | |||||
| if (lhs.dtype.is_floating() || rhs.dtype.is_floating()) | |||||
| { | |||||
| var diff = tf.abs(lhs - rhs); | |||||
| return new NDArray(gen_math_ops.greater_equal(diff, new NDArray(1e-5).astype(diff.dtype))); | |||||
| } | |||||
| else | |||||
| { | |||||
| return new NDArray(math_ops.not_equal(lhs, rhs)); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -5,6 +5,23 @@ | |||||
| <LangVersion>10</LangVersion> | <LangVersion>10</LangVersion> | ||||
| <Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
| <Version>1.0.0</Version> | <Version>1.0.0</Version> | ||||
| <PackageId>TensorFlow.NET.Hub</PackageId> | |||||
| <PackageLicenseExpression>Apache2.0</PackageLicenseExpression> | |||||
| <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | |||||
| <SignAssembly>true</SignAssembly> | |||||
| <Authors>Yaohui Liu, Haiping Chen</Authors> | |||||
| <Company>SciSharp STACK</Company> | |||||
| <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | |||||
| <Copyright>Apache 2.0, Haiping Chen $([System.DateTime]::UtcNow.ToString(yyyy))</Copyright> | |||||
| <RepositoryUrl>https://github.com/SciSharp/TensorFlow.NET</RepositoryUrl> | |||||
| <RepositoryType>git</RepositoryType> | |||||
| <PackageProjectUrl>http://scisharpstack.org</PackageProjectUrl> | |||||
| <PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&v=4</PackageIconUrl> | |||||
| <PackageTags>TensorFlow, SciSharp, Machine Learning, Deep Learning, TensorFlow Hub, TensorFlow.NET, TF.NET, AI</PackageTags> | |||||
| <Description> | |||||
| Google's TensorFlow Hub full binding in .NET Standard. | |||||
| A library for transfer learning with TensorFlow.NET. | |||||
| </Description> | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| @@ -1,4 +1,4 @@ | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <Project Sdk="Microsoft.NET.Sdk"> | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <TargetFramework>net6</TargetFramework> | <TargetFramework>net6</TargetFramework> | ||||