Browse Source

Slice.NewAxis

tags/v0.12
Oceania2018 6 years ago
parent
commit
82724eb501
4 changed files with 30 additions and 9 deletions
  1. +2
    -1
      src/TensorFlowNET.Core/APIs/tf.array.cs
  2. +17
    -0
      src/TensorFlowNET.Core/Exceptions/StopIteration.cs
  3. +4
    -4
      src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
  4. +7
    -4
      src/TensorFlowNET.Core/Tensors/Tensor.Index.cs

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

@@ -14,6 +14,7 @@
limitations under the License.
******************************************************************************/

using NumSharp;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -25,7 +26,7 @@ namespace Tensorflow
/// <summary>
/// A convenient alias for None, useful for indexing arrays.
/// </summary>
public string newaxis = "";
public Slice newaxis = Slice.NewAxis;

/// <summary>
/// BatchToSpace for N-D tensors of type T.


+ 17
- 0
src/TensorFlowNET.Core/Exceptions/StopIteration.cs View File

@@ -0,0 +1,17 @@
using System;

namespace Tensorflow
{
public class StopIteration : TensorflowException
{
public StopIteration() : base()
{

}

public StopIteration(string message) : base(message)
{

}
}
}

+ 4
- 4
src/TensorFlowNET.Core/TensorFlowNET.Core.csproj View File

@@ -5,7 +5,7 @@
<AssemblyName>TensorFlow.NET</AssemblyName>
<RootNamespace>Tensorflow</RootNamespace>
<TargetTensorFlow>1.14.0</TargetTensorFlow>
<Version>0.11.4</Version>
<Version>0.11.5</Version>
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
<Company>SciSharp STACK</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -17,7 +17,7 @@
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags>
<Description>Google's TensorFlow full binding in .NET Standard.
Docs: https://tensorflownet.readthedocs.io</Description>
<AssemblyVersion>0.11.4.0</AssemblyVersion>
<AssemblyVersion>0.11.5.0</AssemblyVersion>
<PackageReleaseNotes>Changes since v0.10.0:
1. Upgrade NumSharp to v0.20.3.
2. Add DisposableObject class to manage object lifetime.
@@ -31,7 +31,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>
10. Support n-dim indexing for tensor.
11. Add RegisterNoGradient</PackageReleaseNotes>
<LangVersion>7.3</LangVersion>
<FileVersion>0.11.4.0</FileVersion>
<FileVersion>0.11.5.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly>
@@ -63,7 +63,7 @@ Docs: https://tensorflownet.readthedocs.io</Description>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.5.1" />
<PackageReference Include="NumSharp" Version="0.20.3" />
<PackageReference Include="NumSharp" Version="0.20.4" />
</ItemGroup>

<ItemGroup>


+ 7
- 4
src/TensorFlowNET.Core/Tensors/Tensor.Index.cs View File

@@ -27,11 +27,10 @@ namespace Tensorflow
{
public Tensor this[int idx] => slice(idx);

public Tensor this[params string[] slices]
public Tensor this[params Slice[] slices]
{
get
{
var slice_spec = slices.Select(x => new Slice(x)).ToArray();
var begin = new List<int>();
var end = new List<int>();
var strides = new List<int>();
@@ -41,9 +40,9 @@ namespace Tensorflow
var (begin_mask, end_mask) = (0, 0);
var ellipsis_mask = 0;

foreach (var s in slice_spec)
foreach (var s in slices)
{
if(s.IsNewAxis)
if (s.IsNewAxis)
{
begin.Add(0);
end.Add(0);
@@ -113,6 +112,10 @@ namespace Tensorflow
}
}

public Tensor this[params string[] slices]
=> this[slices.Select(x => new Slice(x)).ToArray()];


public Tensor slice(Slice slice)
{
var slice_spec = new int[] { slice.Start.Value };


Loading…
Cancel
Save