public MainWindow() { InitializeComponent(); _staticModel = new Model.StaticModel(); listBox.ItemsSource = _staticModel.GetLayerTypesLink(); listBox1.ItemsSource = _staticModel.GetLayerNodesLink(); }
public void Deserialize(System.IO.StreamReader reader, StaticModel staticModel) { var serializer = JsonConvert.DeserializeObject <Serializer>(reader.ReadToEnd()); var types = staticModel.GetLayerTypesLink(); staticModel.GetLayerNodesLink().Clear(); var batch_size = ""; var dtype = ""; var has_input = false; foreach (var layer in serializer.Config.Layers) { staticModel.AddNode(types.FirstOrDefault(t => t.LayerName == layer.ClassName)); var node = staticModel.GetLayerNodesLink().Last(); foreach (var param in layer.Config) { string str; if (param.Value is JArray arr) { str = arr.ToString().Replace("[", "").Replace("]", "").Replace("\n", "").Replace("\r", ""); } else { str = param.Value.ToString(); } switch (param.Key) { case "batch_input_shape": batch_size = str; break; case "dtype": dtype = str; break; default: node.Values[param.Key] = str; break; } if (string.IsNullOrEmpty(dtype) || string.IsNullOrEmpty(batch_size) || has_input) { continue; } staticModel.AddNode(types.FirstOrDefault(t => t.LayerName == "Input"), 0); var input = staticModel.GetLayerNodesLink().First(); input.Values["dtype"] = dtype; input.Values["batch_input_shape"] = batch_size; has_input = true; } } }
public MainWindow() { InitializeComponent(); _staticModel = new StaticModel(); ThrowIf.Variable.IsNull(listBox, nameof(listBox)); ThrowIf.Variable.IsNull(listBox1, nameof(listBox1)); listBox.ItemsSource = _staticModel.GetLayerTypesLink(); listBox1.ItemsSource = _staticModel.GetLayerNodesLink(); textBox_Copy.Text = _staticModel.DataType; textBox_Copy1.Text = _staticModel.BatchSize; }
public void Deserialize([NotNull] StreamReader reader, [NotNull] StaticModel staticModel) { ThrowIf.Variable.IsNull(reader, nameof(reader)); ThrowIf.Variable.IsNull(staticModel, nameof(staticModel)); var serializer = JsonConvert.DeserializeObject <Serializer>(reader.ReadToEnd()); ThrowIf.Variable.IsNull(serializer, nameof(serializer)); ThrowIf.Variable.IsNull(serializer.Config, nameof(serializer.Config)); ThrowIf.Variable.IsNull(serializer.Config.Layers, nameof(serializer.Config.Layers)); var types = staticModel.GetLayerTypesLink(); staticModel.GetLayerNodesLink().Clear(); foreach (var layer in serializer.Config.Layers) { staticModel.AddNode(types.FirstOrDefault(t => t.LayerName == layer.ClassName)); var node = staticModel.GetLayerNodesLink().Last(); ThrowIf.Variable.IsNull(node, nameof(node)); ThrowIf.Variable.IsNull(layer.Config, nameof(layer.Config)); foreach (var param in layer.Config) { string str; if (param.Value is JArray arr) { str = arr.ToString().Replace("[", "").Replace("]", "").Replace("\n", "").Replace("\r", ""); } else { ThrowIf.Variable.IsNull(param.Value, nameof(param.Value)); str = param.Value.ToString(); } switch (param.Key) { case "batch_input_shape": staticModel.BatchSize = str; break; case "dtype": staticModel.DataType = str; break; default: node.Values[param.Key] = str; break; } } } }