Skip to content

Commit c59d64f

Browse files
committed
Graph network JSON serialization improved
1 parent 73a306d commit c59d64f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

NeuralNetwork.NET/Networks/Graph/ComputationGraphJsonConverter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using NeuralNetworkNET.APIs.Interfaces;
55
using NeuralNetworkNET.Networks.Graph.Nodes;
66
using Newtonsoft.Json;
7+
using Newtonsoft.Json.Converters;
78
using Newtonsoft.Json.Linq;
89

910
namespace NeuralNetworkNET.Networks.Graph
@@ -34,7 +35,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
3435
{
3536
case ProcessingNode processing:
3637
jNode.Add("Parent", map[processing.Parent]);
37-
jNode.Add("Layer", JToken.FromObject(processing.Layer));
38+
IList<JsonConverter> converters = new List<JsonConverter> { new StringEnumConverter() };
39+
jNode.Add("Layer", JToken.FromObject(processing.Layer, JsonSerializer.CreateDefault(new JsonSerializerSettings { Converters = converters })));
3840
break;
3941
case DepthConcatenationNode concatenation:
4042
jNode.Add("Parents", new JArray(concatenation.Parents.Select(child => map[child]).ToList()));

0 commit comments

Comments
 (0)