Skip to content

Commit

Permalink
Merge pull request #1282 from eLDoherty/patch-2
Browse files Browse the repository at this point in the history
fix: Resolve fixed-size array issue
  • Loading branch information
Oceania2018 authored Jan 22, 2025
2 parents 6a2d7e1 + b6c5d26 commit 67f8b61
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/TensorFlowNET.Keras/Engine/Functional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void ComputeTensorUsageCount()
var (nodes_in_decreasing_depth, layer_indices) = BuildMap(outputs);
var network_nodes = nodes_in_decreasing_depth
.Select(node => MakeNodeKey(node.Layer.Name, node.Layer.InboundNodes.IndexOf(node)))
.ToArray();
.ToList();

var nodes_depths = new Dictionary<INode, int>();
var layers_depths = new Dictionary<ILayer, int>();
Expand Down Expand Up @@ -221,7 +221,7 @@ void ComputeTensorUsageCount()
layers_depths[input_layer] = 0;
layer_indices[input_layer] = -1;
nodes_depths[input_layer.InboundNodes[0]] = 0;
network_nodes.add(MakeNodeKey(input_layer.Name, 0));
network_nodes.Add(MakeNodeKey(input_layer.Name, 0));
}
}

Expand All @@ -231,15 +231,15 @@ void ComputeTensorUsageCount()
{
if (!nodes_by_depth.ContainsKey(depth))
nodes_by_depth[depth] = new List<INode>();
nodes_by_depth[depth].append(node);
nodes_by_depth[depth].Add(node);
}

var layers_by_depth = new Dictionary<int, List<ILayer>>();
foreach (var (layer, depth) in enumerate(layers_depths))
{
if (!layers_by_depth.ContainsKey(depth))
layers_by_depth[depth] = new List<ILayer>();
layers_by_depth[depth].append(layer);
layers_by_depth[depth].Add(layer);
}

// Get sorted list of layer depths.
Expand All @@ -260,7 +260,7 @@ void ComputeTensorUsageCount()
// Get sorted list of node depths.
depth_keys = nodes_by_depth.Keys.OrderBy(x => x).Reverse();

return (network_nodes, nodes_by_depth, layers, layers_by_depth);
return (network_nodes.ToArray(), nodes_by_depth, layers, layers_by_depth);
}

string MakeNodeKey(string layer_name, int node_index)
Expand Down

0 comments on commit 67f8b61

Please sign in to comment.