Skip to content

Commit c2138b2

Browse files
committed
tf.reduce_prod, tf.add_to_collections, tf.identity. SciSharp#396
1 parent f1a3881 commit c2138b2

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/TensorFlowNET.Core/APIs/tf.array.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ public Tensor expand_dims(Tensor input, int axis = -1, string name = null, int d
9494
public Tensor fill<T>(Tensor dims, T value, string name = null)
9595
=> gen_array_ops.fill(dims, value, name: name);
9696

97+
/// <summary>
98+
/// Return a tensor with the same shape and contents as input.
99+
/// </summary>
100+
/// <param name="input"></param>
101+
/// <param name="name"></param>
102+
/// <returns></returns>
103+
public static Tensor identity(Tensor input, string name = null)
104+
=> array_ops.identity(input, name: name);
105+
97106
/// <summary>
98107
/// Gather slices from params axis axis according to indices.
99108
/// </summary>

src/TensorFlowNET.Core/APIs/tf.math.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,17 @@ public Tensor reduce_any(Tensor input_tensor, int axis = 0, bool keepdims = fals
414414
public Tensor reduce_all(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
415415
=> math_ops.reduce_all(input_tensor, axis: axis, keepdims: keepdims, name: name);
416416

417+
/// <summary>
418+
/// Computes the product of elements across dimensions of a tensor.
419+
/// </summary>
420+
/// <param name="input_tensor"></param>
421+
/// <param name="axis"></param>
422+
/// <param name="keepdims"></param>
423+
/// <param name="name"></param>
424+
/// <returns></returns>
425+
public Tensor reduce_prod(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
426+
=> math_ops.reduce_prod(input_tensor, axis: axis, keepdims: keepdims, name: name);
427+
417428
/// <summary>
418429
/// Computes the sum of elements across dimensions of a tensor.
419430
/// </summary>

src/TensorFlowNET.Core/APIs/tf.ops.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
******************************************************************************/
1616

17+
using System.Collections.Generic;
18+
1719
namespace Tensorflow
1820
{
1921
public partial class tensorflow
2022
{
23+
public void add_to_collection<T>(string name, T value)
24+
=> get_default_graph().add_to_collection(name, value);
25+
26+
public void add_to_collections<T>(List<string> names, T value)
27+
=> get_default_graph().add_to_collections(names, value);
28+
2129
public Tensor assign(Tensor @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null)
2230
=> state_ops.assign(@ref, value, validate_shape, use_locking, name);
2331

0 commit comments

Comments
 (0)