forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimizer.py.cs
More file actions
46 lines (39 loc) · 1010 Bytes
/
optimizer.py.cs
File metadata and controls
46 lines (39 loc) · 1010 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Framework;
namespace Tensorflow
{
public class optimizer
{
public static _OptimizableVariable _get_processor(RefVariable v)
{
return new _RefVariableProcessor(v);
}
}
public class _RefVariableProcessor : _OptimizableVariable
{
private RefVariable _v;
public _RefVariableProcessor(RefVariable v)
{
_v = v;
}
public Tensor target()
{
return _v._ref();
}
public Operation update_op(Optimizer optimizer, Tensor g)
{
Operation update_op = null;
if (g.Tag == null)
{
update_op = optimizer._apply_dense(g, _v);
}
else if (g.Tag is IndexedSlices)
{
return optimizer._apply_sparse_duplicate_indices(g, _v);
}
return update_op;
}
}
}