forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTapeTensor.cs
More file actions
29 lines (23 loc) · 704 Bytes
/
TapeTensor.cs
File metadata and controls
29 lines (23 loc) · 704 Bytes
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
using static Tensorflow.Binding;
namespace Tensorflow.Gradients
{
public class TapeTensor
{
Tensor tensor;
long id => tensor.Id;
TF_DataType dtype => tensor.dtype;
Shape shape => tensor.shape;
public TapeTensor(Tensor tensor)
{
this.tensor = tensor;
}
public long GetID() => tensor.Id;
public Tensor GetTensor() => tensor;
public Tensor ZerosLike()
=> tf.zeros(shape: shape, dtype: dtype);
public Tensor OnesLike()
=> tf.ones(shape: shape, dtype: dtype);
public override string ToString()
=> $"{id}, {shape}, {dtype.as_numpy_name()}";
}
}