/// <summary> /// Save the parameters to the string. /// <remarks>This should get called from save(). /// The format is binary and not necessarily fit for human consumption.</remarks> /// </summary> public void PSave(BinaryWriter writer) { foreach (string key in _params.Keys) { string s = String.Format("{0}={1}", key, _params[key]); BinIO.string_write(writer, s); //writer.Write(String.Format("{0}={1}\n", key, _params[key])); } BinIO.string_write(writer, "END_OF_PARAMETERS=HERE"); //writer.Write("END_OF_PARAMETERS=HERE\n"); }
// saving and loading public virtual void Save(BinaryWriter writer) { BinIO.magic_write(writer, Name); this.PSave(writer); BinIO.string_write(writer, "<component>"); foreach (string wname in _wrappers_dict.Keys) { BinIO.string_write(writer, "<item>"); Global.Debugf("iodetail", "writing {0} {1}", Name, wname); BinIO.string_write(writer, wname); _wrappers_dict[wname].Save(writer); BinIO.string_write(writer, "</item>"); } BinIO.string_write(writer, "</component>"); }
public static void save_component(BinaryWriter writer, IComponent comp) { if (comp == null) { Global.Debugf("iodetail", "{0}[writing OBJ:NULL]", level); BinIO.string_write(writer, "<null/>"); } else { Global.Debugf("iodetail", "{0}[writing OBJ:{1}]", level, comp.Name); level++; BinIO.string_write(writer, "<object>"); BinIO.string_write(writer, comp.Name); comp.Save(writer); BinIO.string_write(writer, "</object>"); level--; Global.Debugf("iodetail", "{0}[done]", level); } }
public override void Save(BinaryWriter writer) { if (lenetWrap.IsEmpty) { BinIO.string_write(writer, "<null/>"); return; } double[] dbuffer; int size; // receive buffer from wrapped lenet lenetWrap.SaveNetworkToBuffer(out size, out dbuffer); lenetparam.Resize(size); for (int i = 0; i < size; i++) { lenetparam.UnsafePut1d(i, dbuffer[i]); } BinIO.string_write(writer, "<object>"); //BinIO.string_write(writer, comp.Name); // write lenet arguments BinIO.scalar_write(writer, lenetWrap.Classes.Length); for (int i = 0; i < lenetWrap.Classes.Length; i++) { BinIO.scalar_write(writer, lenetWrap.Classes[i]); } BinIO.scalar_write(writer, Convert.ToByte(lenetWrap.TanhSigmoid)); BinIO.scalar_write(writer, Convert.ToByte(lenetWrap.NetNorm)); BinIO.scalar_write(writer, Convert.ToByte(lenetWrap.AsciiTarget)); // save Narray to stream BinIO.narray_write(writer, lenetparam); BinIO.string_write(writer, "</object>"); }