forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshape_utils.cs
More file actions
44 lines (40 loc) · 1.26 KB
/
shape_utils.cs
File metadata and controls
44 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Linq;
using Tensorflow.Eager;
using static Tensorflow.Binding;
namespace Tensorflow
{
public class shape_utils
{
public static Tensor static_or_dynamic_map_fn(Func<Tensor, Tensor> fn, Tensor elems, TF_DataType[] dtypes = null,
int parallel_iterations = 32, bool back_prop = true)
{
var outputs = tf.unstack(elems).Select(arg => fn(arg)).ToArray();
throw new NotImplementedException("");
}
public static Shape from_object_array(object[] shape)
{
var dims = shape.Select(x =>
{
if (x is KerasTensor kt && kt.inferred_value != null)
{
return kt.inferred_value.as_int_list()[0];
}
else if (x is EagerTensor et && et.dtype == TF_DataType.TF_INT32)
{
return et.ToArray<int>()[0];
}
else if (x is int i)
{
return i;
}
else if (x is long l)
{
return l;
}
throw new NotImplementedException();
}).ToArray();
return new Shape(dims);
}
}
}