diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs new file mode 100644 index 00000000..b37612c8 --- /dev/null +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs @@ -0,0 +1,15 @@ +using NumSharp; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tensorflow +{ + public partial class Tensor + { + public Tensor Pack(object[] sequences) + { + return sequences[0] as Tensor; + } + } +} diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.cs b/src/TensorFlowNET.Core/Tensors/Tensor.cs index 943edaaf..99a373c4 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.cs @@ -39,7 +39,7 @@ namespace Tensorflow /// Internally, TensorFlow represents tensors as n-dimensional arrays of base datatypes. /// [SuppressMessage("ReSharper", "ConvertToAutoProperty")] - public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray + public partial class Tensor : DisposableObject, ITensorOrOperation, _TensorLike, ITensorOrTensorArray, IPackable { private readonly int _id; private readonly Operation _op; diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.cs index bfd90a75..b3099799 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorShape.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorShape.cs @@ -125,6 +125,9 @@ namespace Tensorflow { get { + if (!slice.Stop.HasValue) + slice.Stop = dims.Length - slice.Start + 1; + if (slice.Start.HasValue == false || slice.Length.HasValue == false) throw new ArgumentException("Slice must has Start and Length.");