forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayer.Layers.cs
More file actions
44 lines (40 loc) · 1.45 KB
/
Layer.Layers.cs
File metadata and controls
44 lines (40 loc) · 1.45 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.Collections.Generic;
using System.Linq;
namespace Tensorflow.Keras.Engine
{
public partial class Layer
{
public virtual List<ILayer> Layers => _self_tracked_trackables;
protected void StackLayers(params ILayer[] layers)
{
_self_tracked_trackables.AddRange(layers);
}
public virtual Shape ComputeOutputShape(Shape input_shape)
=> throw new NotImplementedException("");
protected List<IVariableV1> _gather_children_variables(bool include_trainable = false, bool include_non_trainable = false)
{
List<IVariableV1> res = new();
var nested_layers = _flatten_layers(false, false);
foreach (var layer in nested_layers)
{
if (layer is Layer l)
{
if (include_trainable == true && include_non_trainable == true)
{
res.AddRange(l.Variables);
}
else if (include_trainable == true && include_non_trainable == false)
{
res.AddRange(l.TrainableVariables);
}
else if(include_trainable == false && include_non_trainable == true)
{
res.AddRange(l.NonTrainableVariables);
}
}
}
return res;
}
}
}