MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
RawProtoFile.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6
7namespace MyCaffe.basecode
8{
12 public class RawProtoFile
13 {
17 public RawProtoFile()
18 {
19 }
20
26 public static void SaveToFile(RawProto p, string strFileName)
27 {
28 string strBody = "";
29
30 if (p.Name != "root")
31 {
32 strBody = p.ToString();
33 }
34 else
35 {
36 foreach (RawProto child in p.Children)
37 {
38 strBody += child.ToString();
39 strBody += Environment.NewLine;
40 }
41 }
42
43 using (StreamWriter sw = new StreamWriter(strFileName))
44 {
45 sw.Write(strBody);
46 }
47 }
48
54 public static RawProto LoadFromFile(string strFileName)
55 {
56 string strBody = "";
57
58 using (StreamReader sr = new StreamReader(strFileName))
59 {
60 strBody = sr.ReadToEnd();
61 }
62
63 return RawProto.Parse(strBody);
64 }
65 }
66}
The RawProtoFile class writes and reads prototxt to and from a file.
Definition: RawProtoFile.cs:13
static RawProto LoadFromFile(string strFileName)
Loads a RawProto from a prototxt file.
Definition: RawProtoFile.cs:54
RawProtoFile()
The RawProtoFile constructor.
Definition: RawProtoFile.cs:17
static void SaveToFile(RawProto p, string strFileName)
Saves the RawProto to a file.
Definition: RawProtoFile.cs:26
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
string Name
Returns the name of the node.
Definition: RawProto.cs:71
RawProtoCollection Children
Returns a collection of this nodes child nodes.
Definition: RawProto.cs:96
override string ToString()
Returns the RawProto as its full prototxt string.
Definition: RawProto.cs:681
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12