summaryrefslogtreecommitdiff
path: root/src/TNetLib/BlockArray.h
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
commitcccccbf6cca94a3eaf813b4468453160e91c332b (patch)
tree23418cb73a10ae3b0688681a7f0ba9b06424583e /src/TNetLib/BlockArray.h
downloadtnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.gz
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.bz2
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.zip
First commit
Diffstat (limited to 'src/TNetLib/BlockArray.h')
-rw-r--r--src/TNetLib/BlockArray.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/TNetLib/BlockArray.h b/src/TNetLib/BlockArray.h
new file mode 100644
index 0000000..e6a8657
--- /dev/null
+++ b/src/TNetLib/BlockArray.h
@@ -0,0 +1,85 @@
+#ifndef _BLOCK_ARRAY_H_
+#define _BLOCK_ARRAY_H_
+
+
+#include "Component.h"
+
+#include "Matrix.h"
+#include "Vector.h"
+
+
+namespace TNet {
+
+ class Network;
+
+ class BlockArray : public Component
+ {
+ public:
+
+ BlockArray(size_t nInputs, size_t nOutputs, Component *pPred);
+ ~BlockArray();
+
+ ComponentType GetType() const;
+ const char* GetName() const;
+
+ void PropagateFnc(const Matrix<BaseFloat>& X, Matrix<BaseFloat>& Y);
+ void BackpropagateFnc(const Matrix<BaseFloat>& X, Matrix<BaseFloat>& Y);
+
+ void Update();
+
+ void ReadFromStream(std::istream& rIn);
+ void WriteToStream(std::ostream& rOut);
+
+ //:TODO:
+ Component* Clone() const { KALDI_ERR << "Unimplemented"; }
+
+ protected:
+ std::vector<Network*> mBlocks; ///< vector with networks, one network is one block
+ size_t mNBlocks;
+ };
+
+
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ // INLINE FUNCTIONS
+ // BlockArray::
+ inline
+ BlockArray::
+ BlockArray(size_t nInputs, size_t nOutputs, Component *pPred)
+ : Component(nInputs, nOutputs, pPred),
+ mNBlocks(0)
+ { }
+
+
+ inline
+ BlockArray::
+ ~BlockArray()
+ {
+ for(int i=0; i<mBlocks.size(); i++) {
+ delete mBlocks[i];
+ }
+ mBlocks.clear();
+ }
+
+ inline Component::ComponentType
+ BlockArray::
+ GetType() const
+ {
+ return Component::BLOCK_ARRAY;
+ }
+
+ inline const char*
+ BlockArray::
+ GetName() const
+ {
+ return "<blockarray>";
+ }
+
+
+
+} //namespace
+
+
+
+#endif