//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Functions for branched models. </summary> /// /// <param name="path"> Full pathname of the file. </param> /// /// <returns> The net work. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// public static FunctionDictionary LoadNetWork(string path) { FunctionDictionary functionDictionary = new FunctionDictionary(); using (FileStream stream = new FileStream(path, FileMode.Open)) { NetParameter netparam = Serializer.Deserialize <NetParameter>(stream); foreach (V1LayerParameter layer in netparam.Layers) { Function func = CreateFunction(layer); if (func != null) { functionDictionary.Add(func); } } foreach (LayerParameter layer in netparam.Layer) { Function func = CreateFunction(layer); if (func != null) { functionDictionary.Add(func); } } } return(functionDictionary); }
//分岐ありモデル用関数 public static FunctionDictionary <T> LoadNetWork <T>(string path) where T : unmanaged, IComparable <T> { FunctionDictionary <T> functionDictionary = new FunctionDictionary <T>(); using (FileStream stream = new FileStream(path, FileMode.Open)) { NetParameter netparam = Serializer.Deserialize <NetParameter>(stream); foreach (V1LayerParameter layer in netparam.Layers) { Function <T> func = CreateFunction <T>(layer); if (func != null) { functionDictionary.Add(func); } } foreach (LayerParameter layer in netparam.Layer) { Function <T> func = CreateFunction <T>(layer); if (func != null) { functionDictionary.Add(func); } } } return(functionDictionary); }
/// <param name="port">TCP port for network connections</param> /// <param name="cmdLength">Length of command in bytes</param> /// <param name="pctLength">Length of packet size to send and recieve</param> public NetworkServer(int port = 1, int cmdLength = 1, int pctLength = 1024) { mainListener = new TcpListener(IPAddress.Any, port); commandLength = cmdLength; packetSize = pctLength; active = true; Functions = new FunctionDictionary(); }
public static void Run(ResnetModel modelType) { OpenFileDialog ofd = new OpenFileDialog { Filter = "画像ファイル(*.jpg;*.png;*.gif;*.bmp)|*.jpg;*.png;*.gif;*.bmp|すべてのファイル(*.*)|*.*" }; if (ofd.ShowDialog() == DialogResult.OK) { int resnetId = (int)modelType; Console.WriteLine("Mean Loading."); string meanFilePath = InternetFileDownloader.Donwload(DOWNLOAD_URL_MEAN, MODEL_FILE_MEAN, MODEL_FILE_MEAN_HASH); NdArray mean = CaffemodelDataLoader.ReadBinary(meanFilePath); Console.WriteLine("Model Loading."); string modelFilePath = InternetFileDownloader.Donwload(Urls[resnetId], FileNames[resnetId], Hashes[resnetId]); FunctionDictionary nn = CaffemodelDataLoader.LoadNetWork(modelFilePath); string[] classList = File.ReadAllLines(CLASS_LIST_PATH); //GPUを初期化 foreach (FunctionStack resNetFunctionBlock in nn.FunctionBlocks) { SwitchGPU(resNetFunctionBlock); } Console.WriteLine("Model Loading done."); do { //ネットワークへ入力する前に解像度を 224px x 224px x 3ch にしておく Bitmap baseImage = new Bitmap(ofd.FileName); Bitmap resultImage = new Bitmap(224, 224, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(resultImage); g.InterpolationMode = InterpolationMode.Bilinear; g.DrawImage(baseImage, 0, 0, 224, 224); g.Dispose(); NdArray imageArray = NdArrayConverter.Image2NdArray(resultImage, false, true); imageArray -= mean; imageArray.ParentFunc = null; Console.WriteLine("Start predict."); Stopwatch sw = Stopwatch.StartNew(); NdArray result = nn.Predict(imageArray)[0]; sw.Stop(); Console.WriteLine("Result Time : " + (sw.ElapsedTicks / (Stopwatch.Frequency / (1000L * 1000L))).ToString("n0") + "μs"); int maxIndex = Array.IndexOf(result.Data, result.Data.Max()); Console.WriteLine("[" + result.Data[maxIndex] + "] : " + classList[maxIndex]); } while (ofd.ShowDialog() == DialogResult.OK); } }
public void PL1_Setup() { BivalenceWorld world = new BivalenceWorld(); WorldParameter parameter = CreateBiggerParameter(); world.Check(parameter); PL1Structure structure = world.GetPl1Structure(); _predDictionary = structure.GetPredicates(); _constDictionary = structure.GetConsts(); _funcDictionary = structure.GetFunctions(); }
static void Main(string[] args) { var functions = FunctionDictionary.GetFunctions(@"C:\ProgramData\Schneider Electric\Citect SCADA 2016\User"); LogCsv logCsv = new LogCsv(@"C:\QR_PSCS\Logs\cicodeFunctions.txt", true); foreach (var func in functions) { foreach (var kvp in func.FunctionLocations) { logCsv.WriteToFile("{0},{1},{2}", func.FileName, kvp.Key, kvp.Value); } } logCsv.CloseFile(); //list of function ref in cicode FunctionDictionary.FunctionRefExistInCicode(); //list of function ref in dbf //FunctionDictionary.FunctionRefExistInDBFs(@"C:\ProgramData\Schneider Electric\Citect SCADA 2016\User", "QRTP"); }
public IExpressionData Evaluate() { return(FunctionDictionary.Invoke(name, parameters)); }
public PL1DataStructure(ConstDictionary @const, PredicateDictionary predicates, FunctionDictionary functions) { _const = @const; _predicates = predicates; _functions = functions; }