Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if sys.platform == 'darwin':
elif sys.platform == 'linux2':
libname = 'libarac.so'
frameworksflags = ''
linkflags = ''
linkflags = ''
else:
raise SystemExit("Cannot build on %s." % sys.platform)

Expand All @@ -27,15 +27,15 @@ NUMPYPATH = numpy.distutils.misc_util.get_numpy_include_dirs()
# First compile and link the library.
libenv = Environment(LIBS=['m', 'blas'], CPPPATH=CPPPATH, LIBPATH=LIBPATH,
SHLIBPREFIX="", CCFLAGS=CCFLAGS)
library_globs = ['src/cpp/*.cpp',
'src/cpp/common/*.cpp',
'src/cpp/utilities/*.cpp',
'src/cpp/datasets/*.cpp',
'src/cpp/optimization/*.cpp',
'src/cpp/optimization/descent/*.cpp',
'src/cpp/structure/*.cpp',
'src/cpp/structure/connections/*.cpp',
'src/cpp/structure/modules/*.cpp',
library_globs = ['src/cpp/*.cpp',
'src/cpp/common/*.cpp',
'src/cpp/utilities/*.cpp',
'src/cpp/datasets/*.cpp',
'src/cpp/optimization/*.cpp',
'src/cpp/optimization/descent/*.cpp',
'src/cpp/structure/*.cpp',
'src/cpp/structure/connections/*.cpp',
'src/cpp/structure/modules/*.cpp',
'src/cpp/structure/networks/*.cpp',
'src/cpp/structure/networks/mdrnns/*.cpp']
lib = libenv.SharedLibrary(libname, sum([Glob(i) for i in library_globs], []))
Expand All @@ -51,10 +51,10 @@ swigenv = Environment(SWIGFLAGS=['-python', '-c++', '-outdir', 'src/python/arac'
FRAMEWORKSFLAGS=frameworksflags,
LINKFLAGS=linkflags,
LIBPATH=LIBPATH,
LDMODULEPREFIX='src/python/arac/_',
LDMODULEPREFIX='src/python/arac/_',
LDMODULESUFFIX = '.so',
)
swig = swigenv.LoadableModule('cppbridge',
swig = swigenv.LoadableModule('cppbridge',
['src/swig/cppbridge.i'])

# Declare some dependencies.
Expand Down
1,178 changes: 589 additions & 589 deletions docs/Doxyfile

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions examples/mdrnn/mnist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ SupervisedDataset<double*, double*> make_dataset()
SupervisedDataset<double*, double*> ds(insize, insize * outsize);
double* sample_p = new double[insize];
double* target_p = new double[outsize];

memset(sample_p, 0, sizeof(double) * insize);
memset(target_p, 0, sizeof(double) * outsize * insize);

ds.append(sample_p, target_p);
return ds;
}
Expand All @@ -35,15 +35,15 @@ Network make_network()
{
int hidden = 5;
Network net;

Mdrnn<MdlstmLayer>* inlayer_p = new Mdrnn<MdlstmLayer>(2, hidden);

inlayer_p->set_sequence_shape(0, 28);
inlayer_p->set_sequence_shape(1, 28);
inlayer_p->set_block_shape(0, 1);
inlayer_p->set_block_shape(1, 1);
inlayer_p->sort();

PartialSoftmaxLayer* outlayer_p = \
new PartialSoftmaxLayer(insize * outsize, outsize);

Expand All @@ -55,16 +55,16 @@ Network make_network()
<< std::endl;

WeightShareConnection* con_p = new WeightShareConnection(
inlayer_p, outlayer_p,
inlayer_p, outlayer_p,
hidden, outsize);

net.add_module(inlayer_p, Network::InputModule);
net.add_module(outlayer_p, Network::OutputModule);

net.add_connection(con_p);

net.randomize();

return net;
}

Expand Down
12 changes: 6 additions & 6 deletions examples/xor/xor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SupervisedDataset<double*, double*> make_dataset()
data_p[0] = 0;
data_p[1] = 0;
data_p[2] = 0;

data_p[3] = 0;
data_p[4] = 1;
data_p[5] = 1;
Expand All @@ -31,12 +31,12 @@ SupervisedDataset<double*, double*> make_dataset()
data_p[9] = 1;
data_p[10] = 1;
data_p[11] = 0;

ds.append(data_p, data_p + 2);
ds.append(data_p + 3, data_p + 5);
ds.append(data_p + 6, data_p + 8);
ds.append(data_p + 9, data_p + 11);

return ds;
}

Expand All @@ -51,17 +51,17 @@ Network make_network()
FullConnection* con1_p = new FullConnection(inlayer_p, hidden_p);
FullConnection* con2_p = new FullConnection(hidden_p, outlayer_p);
FullConnection* con3_p = new FullConnection(bias_p, hidden_p);

net.add_module(inlayer_p, Network::InputModule);
net.add_module(hidden_p);
net.add_module(bias_p);
net.add_module(outlayer_p, Network::OutputModule);
net.add_connection(con1_p);
net.add_connection(con2_p);
net.add_connection(con3_p);

net.randomize();

return net;
}

Expand Down
32 changes: 16 additions & 16 deletions src/cpp/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ namespace arac {
namespace common {

///
/// Buffer objects hold pointers to arrays which are serving as
/// inputs/outputs/errors/etc. to modules.
/// Buffer objects hold pointers to arrays which are serving as
/// inputs/outputs/errors/etc. to modules.
///
/// A buffer is organized in different rows which are held as a vector of double
/// pointers.
/// A buffer may either "own" its arrays or not own them. In the first case, the
/// buffer frees the memory of the arrays on destruction.
/// pointers.
/// A buffer may either "own" its arrays or not own them. In the first case, the
/// buffer frees the memory of the arrays on destruction.
///

class Buffer
{
public:

Buffer(size_t rowsize, bool owner=true);
virtual ~Buffer();

///
/// Add the contents at the given pointer to the last buffer row. If an
/// index is given, the content will be added to that buffer row.
///
void add(double* addend_p, int index=-1);

///
/// Append an empty row to the buffer's contents.
///
void expand();

///
/// Set all the contents to zero.
/// Set all the contents to zero.
///
void clear();

Expand All @@ -58,9 +58,9 @@ class Buffer
/// does not own the memory.
///
void free_memory();

///
/// Add the given pointer as a row. Attention: This removes ownership
/// Add the given pointer as a row. Attention: This removes ownership
/// for all buffers.
///
void append(double* row);
Expand Down Expand Up @@ -112,7 +112,7 @@ class Buffer
bool _contmemory;

// Index that says up to which row the buffer has been used recently. Is
// being reset by .clear() and clear_at(). Is updated by append(),
// being reset by .clear() and clear_at(). Is updated by append(),
// add and operator [].
// The index is an exclusive upper bound.
size_t _dirtyindex;
Expand All @@ -128,7 +128,7 @@ Buffer::rowsize()
}


inline
inline
void
Buffer::set_rowsize(size_t value)
{
Expand All @@ -137,13 +137,13 @@ Buffer::set_rowsize(size_t value)


inline
size_t
size_t
Buffer::size()
{
return _content.size();
}


inline
double*
Buffer::operator[] (size_t index)
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace arac {
namespace common {


typedef std::vector<double*> DoublePtrVec;


Expand Down
4 changes: 2 additions & 2 deletions src/cpp/datasets/datasets.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

namespace arac {
namespace datasets {

typedef SupervisedDataset<arac::datasets::Sequence, arac::datasets::Sequence> SupervisedSequentialDataset;
typedef SupervisedDataset<arac::datasets::Sequence, double*> SupervisedSemiSequentialDataset;
typedef SupervisedDataset<double*, double*> SupervisedSimpleDataset;
typedef UnsupervisedDataset<double*> UnsupervisedSimpleDataset;
typedef UnsupervisedDataset<arac::datasets::Sequence> UnsupervisedSequenceDataset;

} } // Namespace


Expand Down
6 changes: 3 additions & 3 deletions src/cpp/datasets/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Sequence::Sequence(int length, int itemsize, double* data_p) :
_length(length),
_itemsize(itemsize),
_data_p(data_p)
{
{
}


Sequence::~Sequence()
Sequence::~Sequence()
{

}
12 changes: 6 additions & 6 deletions src/cpp/datasets/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@

namespace arac {
namespace datasets {


class Sequence

class Sequence
{
public:

Sequence(int length, int itemsize, double* data_p);
virtual ~Sequence();

int length() const;
int itemsize() const;
double* operator[](int index);

private:
int _length;
int _itemsize;
double* _data_p;
};


inline
inline
int
Sequence::length() const
{
Expand Down
Loading