📄 multi_layer.cpp
字号:
/*
nn-utility (Provides neural networking utilities for c++ programmers)
Copyright (C) 2003 Pan Thomakos
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//To contact the author send an email to panthomakos@users.sourceforge.net
#include "nn-utility.h"
using namespace nn_utility;
template<class T> multi_layer<T>::multi_layer(){
length = 0;
ClearVector( NULL_VECTOR, NN_UTIL_SIZE-1, 0.0 ); }
template<class T> void multi_layer<T>::add_recurrent( int functionSelection, int row_, int col_, T value, ... ){
layers[length] = &*(new layer<T>( functionSelection, row_, col_ ));
va_list argument_ptr;
layers[length]->matrix[0][0] = value;
va_start(argument_ptr, value);
for ( int i = 0; i < row_; i++ ){
//the insert if statement determines whether that value has already been placed, since the
//first value is read outside the loop
for ( int e = ( i == 0 ? 1 : 0 ); e < col_; e++ ){
layers[length]->matrix[i][e] = va_arg(argument_ptr, T );
}
}
va_end(argument_ptr);
length++;
}
template<class T> void multi_layer<T>::add_recurrent( int row_, int col_, T value, ... ){
layers[length] = &*(new layer<T>( row_, col_ ));
va_list argument_ptr;
layers[length]->matrix[0][0] = value;
va_start(argument_ptr, value);
for ( int i = 0; i < row_; i++ ){
//the insert if statement determines whether that value has already been placed, since the
//first value is read outside the loop
for ( int e = ( i == 0 ? 1 : 0 ); e < col_; e++ ){
layers[length]->matrix[i][e] = va_arg(argument_ptr, T );
}
}
va_end(argument_ptr);
length++;
}
template<class T> void multi_layer<T>::add_recurrent( int functionSelection, int row_, int col_ ){
layers[length] = &*(new layer<T>( functionSelection, row_, col_ ));
length++;}
template<class T> void multi_layer<T>::add_recurrent( int row_, int col_ ){
layers[length] = &*(new layer<T>( row_, col_ ));
length++; }
template<class T> void multi_layer<T>::add( int row_, int col_, T value, ... ){
layers[length] = &*(new layer<T>());
layers[length]->row = row_;
layers[length]->col = col_;
layers[length]->Next[0] = NULL;
layers[length]->_previous = -1; layers[length]->_next = -1;
for ( int clear = 0; clear < col_; clear++ )
layers[length]->weight[clear] = 0;
va_list argument_ptr;
layers[length]->matrix[0][0] = value;
va_start(argument_ptr, value);
for ( int i = 0; i < row_; i++ ){
//the insert if statement determines whether that value has already been placed, since the
//first value is read outside the loop
for ( int e = ( i == 0 ? 1 : 0 ); e < col_; e++ ){
layers[length]->matrix[i][e] = va_arg(argument_ptr, T );
}
}
va_end(argument_ptr);
if ( length >= 1 ){
layers[length]->Previous[0] = (layers[length-1]);
layers[length]->_previous = 1;
layers[length-1]->Next[0] = layers[length];
layers[length-1]->_next = 1;
}
length++;
}
template<class T> void multi_layer<T>::add( int row_, int col_ ){
layers[length] = &*(new layer<T>());
layers[length]->row = row_;
layers[length]->col = col_;
layers[length]->_previous = -1; layers[length]->_next = -1;
for ( int clear = 0; clear < col_; clear++ )
layers[length]->weight[clear] = 0;
if ( length >= 1 ){
layers[length]->Previous[0] = (layers[length-1]);
layers[length]->_previous = 1;
layers[length-1]->Next[0] = layers[length];
layers[length-1]->_next = 1;
}
length++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -