public void Connect(Layer layer) { _layer = layer; if (args.InputTensors != null) { KerasInputs.AddRange(args.InputTensors); } // Wire up Node to Layers. layer.InboundNodes.Add(this); foreach (var kt in KerasInputs) { if (kt.KerasHistory == null) { continue; } var(inbound_layer, _, _) = kt.KerasHistory; if (inbound_layer != null) { inbound_layer.OutboundNodes.Add(this); } } // Set metadata on outputs. var node_index = layer.InboundNodes.Count - 1; foreach (var(i, tensor) in enumerate(Outputs)) { tensor.KerasHistory = new KerasHistory(layer, node_index, i); } }
public Node(Layer layer, NodeArgs args) { this.args = args; this.Layer = layer; if (args.InputTensors != null) { KerasInputs.AddRange(args.InputTensors); } foreach (var(i, ele) in enumerate(KerasInputs)) { _keras_inputs_ids_and_indices[i] = ele.GetHashCode(); } // Wire up Node to Layers. layer.InboundNodes.Add(this); foreach (var kt in KerasInputs) { if (kt.KerasHistory == null) { continue; } var(inbound_layer, _, _) = kt.KerasHistory; if (inbound_layer != null) { inbound_layer.OutboundNodes.Add(this); } } // Set metadata on outputs. var node_index = layer.InboundNodes.Count - 1; foreach (var(i, tensor) in enumerate(Outputs)) { tensor.KerasHistory = new KerasHistory(layer, node_index, i, tensor); } // Cached for performance. FlatInputIds = KerasInputs.Select(x => x.GetHashCode()).ToArray(); FlatOutputIds = Outputs.Select(x => x.GetHashCode()).ToArray(); }