forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTensor.Assign.cs
More file actions
26 lines (24 loc) · 819 Bytes
/
Tensor.Assign.cs
File metadata and controls
26 lines (24 loc) · 819 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
using NumSharp;
namespace Tensorflow
{
public partial class Tensor
{
/// <summary>
/// Used to keep the original variable when slicing
/// </summary>
public ResourceVariable OriginalVar { get; set; }
public ParsedSliceArgs OriginalVarSlice { get; set; }
public ResourceVariable assign(Tensor tensor)
{
if (OriginalVar != null)
{
OriginalVar.StridedSliceAssign(tensor, OriginalVarSlice);
return OriginalVar;
}
else
{
throw new RuntimeError($"Operation doesn't support. {this.name} is a constant tensor. Make sure to initiate {this.name} from tf.Variable() and declare {this.name} as ResourceVariable or var.");
}
}
}
}