| @@ -96,7 +96,7 @@ namespace Tensorflow.Gradients | |||
| new Tensor[] { non_neg_concat_dim, tf.constant(0) }, | |||
| new Tensor[] { tf.constant(1), tf.constant(-1) }); | |||
| var squeeze_sizes = array_ops.squeeze(slice); | |||
| out_grads = gen_array_ops.split(grad, squeeze_sizes, (int)non_neg_concat_dim.Data<int>()[0]).ToList(); | |||
| out_grads = gen_array_ops.split(grad, squeeze_sizes, (int)non_neg_concat_dim).ToList(); | |||
| } | |||
| else | |||
| { | |||
| @@ -146,7 +146,7 @@ namespace Tensorflow | |||
| string name1 = scope1; | |||
| if (grad_fn != null) | |||
| { | |||
| in_grads = _MaybeCompile(grad_scope, op, out_grads[0].ToArray(), null, grad_fn); | |||
| in_grads = _MaybeCompile(grad_scope, op, out_grads.Select(x => x[0]).ToArray(), null, grad_fn); | |||
| _VerifyGeneratedGradients(in_grads, op); | |||
| } | |||
| @@ -333,7 +333,7 @@ namespace Tensorflow | |||
| throw new ValueError("_AggregatedGrads out_grad.Length == 0"); | |||
| } | |||
| out_grads[i] = out_grad; | |||
| out_grads[i] = new List<Tensor> { out_grad[0] }; | |||
| } | |||
| else | |||
| { | |||
| @@ -141,7 +141,7 @@ namespace Tensorflow | |||
| // Use static rank. | |||
| var rank_diff = weights_rank - labels_rank; | |||
| if (rank_diff == 1) | |||
| weights = (int)array_ops.squeeze(weights_tensor, new int[] { -1 }); | |||
| weights = (float)array_ops.squeeze(weights_tensor, new int[] { -1 }); | |||
| return (labels, predictions, weights_tensor); | |||
| } | |||
| @@ -89,7 +89,7 @@ namespace Tensorflow | |||
| { | |||
| name = scope; | |||
| var minTensor = ops.convert_to_tensor(minval, dtype: dtype, name: "min"); | |||
| var maxTensor = ops.convert_to_tensor(maxval == null ? 1 : maxval, dtype: dtype, name: "max"); | |||
| var maxTensor = ops.convert_to_tensor(maxval == null ? 1 : (int)maxval, dtype: dtype, name: "max"); | |||
| var (seed1, seed2) = random_seed.get_seed(seed); | |||
| if (dtype.is_integer()) | |||
| { | |||
| @@ -1,79 +1,25 @@ | |||
| /***************************************************************************** | |||
| Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. | |||
| Licensed under the Apache License, Version 2.0 (the "License"); | |||
| you may not use this file except in compliance with the License. | |||
| You may obtain a copy of the License at | |||
| http://www.apache.org/licenses/LICENSE-2.0 | |||
| Unless required by applicable law or agreed to in writing, software | |||
| distributed under the License is distributed on an "AS IS" BASIS, | |||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| See the License for the specific language governing permissions and | |||
| limitations under the License. | |||
| ******************************************************************************/ | |||
| using NumSharp; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| namespace Tensorflow | |||
| { | |||
| public partial class Tensor | |||
| { | |||
| public static implicit operator Tensor(bool value) | |||
| /// <summary> | |||
| /// Issue unresolved, will cause name_scope problem. | |||
| /// </summary> | |||
| /// <param name="scalar"></param> | |||
| /*public static implicit operator Tensor(double scalar) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_BOOL); | |||
| } | |||
| public static implicit operator Tensor(sbyte value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_INT8); | |||
| } | |||
| public static implicit operator Tensor(byte value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_INT16); | |||
| } | |||
| public static implicit operator Tensor(ushort value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_UINT16); | |||
| } | |||
| public static implicit operator Tensor(short value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_INT16); | |||
| } | |||
| return constant_op.constant(scalar); | |||
| }*/ | |||
| public static implicit operator Tensor(int value) | |||
| /*public static implicit operator Tensor(int scalar) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_INT32); | |||
| } | |||
| public static implicit operator Tensor(uint value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_UINT32); | |||
| } | |||
| public static implicit operator Tensor(long value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_INT64); | |||
| } | |||
| public static implicit operator Tensor(ulong value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_UINT64); | |||
| } | |||
| public static implicit operator Tensor(float value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_FLOAT); | |||
| } | |||
| public static implicit operator Tensor(double value) | |||
| { | |||
| return tf.constant(value, TF_DataType.TF_DOUBLE); | |||
| } | |||
| return constant_op.constant(scalar); | |||
| }*/ | |||
| public static implicit operator IntPtr(Tensor tensor) | |||
| { | |||
| @@ -19,7 +19,7 @@ namespace TensorFlowNET.UnitTest | |||
| var tensor3 = tf.constant(6.0); // double | |||
| } | |||
| [DataTestMethod] | |||
| /*[DataTestMethod] | |||
| [DataRow(int.MinValue)] | |||
| [DataRow(-1)] | |||
| [DataRow(0)] | |||
| @@ -85,7 +85,7 @@ namespace TensorFlowNET.UnitTest | |||
| var result = sess.run(tensor); | |||
| Assert.IsTrue(result.Data<string>()[0] == str); | |||
| }); | |||
| } | |||
| }*/ | |||
| [TestMethod] | |||
| public void ZerosConst() | |||
| @@ -91,11 +91,14 @@ namespace TensorFlowNET.UnitTest | |||
| var g = tf.gradients(y, new Tensor[] { slice, slice }); | |||
| var r = slice.eval(); | |||
| with(tf.Session(graph), sess => | |||
| { | |||
| var r = sess.run(slice); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r.shape, new[] { 2, 1, 2 })); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r[0].GetData<int>(), new[] { 11, 13 })); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r[1].GetData<int>(), new[] { 51, 53 })); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r.shape, new[] { 2, 1, 2 })); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r[0].GetData<int>(), new[] { 11, 13 })); | |||
| Assert.IsTrue(Enumerable.SequenceEqual(r[1].GetData<int>(), new[] { 51, 53 })); | |||
| }); | |||
| } | |||
| } | |||
| } | |||
| @@ -56,7 +56,7 @@ namespace TensorFlowNET.UnitTest.nest_test | |||
| //# Check that flatten fails if attributes are not iterable | |||
| // with self.assertRaisesRegexp(TypeError, "object is not iterable"): | |||
| // flat = nest.flatten(NestTest.BadAttr()) | |||
| [Ignore] | |||
| [TestMethod] | |||
| public void testFlattenAndPack() | |||
| { | |||
| @@ -380,7 +380,7 @@ namespace TensorFlowNET.UnitTest.nest_test | |||
| // def testHeterogeneousComparison(self): | |||
| // nest.assert_same_structure({"a": 4}, _CustomMapping(a= 3)) | |||
| // nest.assert_same_structure(_CustomMapping(b=3), {"b": 4}) | |||
| [Ignore] | |||
| [TestMethod] | |||
| public void testMapStructure() | |||
| { | |||