📄 netloader.h
字号:
/*************************************************************************** netloader.h - description ------------------- begin : Mon Apr 29 2002 copyright : (C) 2002 by Rudiger Koch email : rkoch@rkoch.org ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#ifndef NETLOADER_H#define NETLOADER_H#include "config.h"#include <amygdala/amygdalaclass.h>#include <amygdala/network.h>#include <map>#include <string>#include <cstdio>namespace Amygdala {class Neuron;class Factory;class NeuronProperties;class SynapseProperties;class NConnector;class SpikeInput;class SpikeOutput;class Properties;/** @class NetLoader netloader.h amygdala/netloader.h * @brief loads networks from file / saves networks to a file * * this class separates loading and saving of Networks from the class Network. It's meant to * be used from class Network only. The file format is XML which is gzip compressed by * default * @author Rudiger Koch * @author Matt Grover * @see Network */class NetLoader: public AmygdalaClass { NetLoader(); ~NetLoader(); NetLoader(NetLoader&); // allow only Network to use this class friend void Network::Save(std::string, bool); friend void Network::Load(std::string, bool);public: /** Load a Network from a file. This takes 2 passes. Pass 1 instantiates all neurons * and ignores the synapses. Pass 2 connects the neurons. * @param filename * @param loadPhysProps */ void LoadXML(std::string filename, bool loadPhysProps); /** save a single Network Instance to a file. * @param filename the file to save the Network * @param compress whether or not to gzip compress the xml file */ void SaveXML(std::string filename, bool compress=true); /** first pass parser function. Used to instantiate everything but synapses */ void SAXStartElement1(string name, const char **attrs); /** a SAX callback - don't use this function */ void SAXEndElement1(std::string name); /** 2nd pass parser function. Used to instantiate all synapses */ void SAXStartElement2(std::string name, const char **attrs); /** a SAX callback - don't use this function */ void SAXEndElement2(std::string name); /** handles all SAX errors - don't use this function */ void SAXError();protected: // Protected attributes /** The Topology object we're currently working on */ Topology *currTop; std::string currNType; AmIdInt currNId; Neuron * currNeuron; NConnector * connector; unsigned int saxErrors; int pass; NeuronProperties * nProps; SynapseProperties * sProps; bool loadPhysProps; AmIdInt postNId; SpikeInput * spikeInput; SpikeOutput * spikeOutput; AmIdInt outputGroup;private: // Private methods void WriteProperties(FILE * netFile, const Properties * nProps, const char * indent); void ParseTopology(const char **attrs); void ParseNeuron(const char **attrs); void ParseProperties(const char **attrs); void ParseSynapse(const char **attrs); void ParseSpikeInput(const char **attrs); void ParseSpikeOutput(const char **attrs); void ParseOutputGroup(const char **attrs); protected: // Protected methods /** @return a string identifying the layer given by IType */ //string LayerTypeStr(LayerType lType); /** Loading is done in 2 passes: in the first pass we * instantiate all layers and neurons. In the second we connect them. */ void SAXPass(std::string filename);};} // namespace Amygdala#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -