diff --git a/SLIDE/Layer.cpp b/SLIDE/Layer.cpp index 577dcc1..c5c291c 100755 --- a/SLIDE/Layer.cpp +++ b/SLIDE/Layer.cpp @@ -86,7 +86,7 @@ Layer::Layer(size_t noOfNodes, int previousLayerNumOfNodes, int layerID, NodeTyp { _Nodes[i].Update(previousLayerNumOfNodes, i, _layerID, type, batchsize, _weights+previousLayerNumOfNodes*i, _bias[i], _adamAvgMom+previousLayerNumOfNodes*i , _adamAvgVel+previousLayerNumOfNodes*i, _train_array); - addtoHashTable(_Nodes[i]._weights, previousLayerNumOfNodes, _Nodes[i]._bias, i); + addtoHashTable(_Nodes[i]._weights, previousLayerNumOfNodes, *_Nodes[i]._bias, i); } auto t2 = std::chrono::high_resolution_clock::now(); auto timeDiffInMiliseconds = std::chrono::duration_cast(t2 - t1).count(); @@ -418,7 +418,7 @@ int Layer::queryActiveNodeandComputeActivations(int** activenodesperlayer, float for (size_t s = 0; s < _noOfNodes; s++) { float tmp = innerproduct(activenodesperlayer[layerIndex], activeValuesperlayer[layerIndex], lengths[layerIndex], _Nodes[s]._weights); - tmp += _Nodes[s]._bias; + tmp += *_Nodes[s]._bias; if (find(label, label + labelsize, s) != label + labelsize) { sortW.push_back(make_pair(-1000000000, s)); what++; diff --git a/SLIDE/Network.cpp b/SLIDE/Network.cpp index 8e580c4..48cd6ea 100755 --- a/SLIDE/Network.cpp +++ b/SLIDE/Network.cpp @@ -245,13 +245,13 @@ int Network::ProcessInput(int **inputIndices, float **inputValues, int *lengths, tmp->_adamAvgMombias = BETA1 * tmp->_adamAvgMombias + (1 - BETA1) * tmp->_tbias; tmp->_adamAvgVelbias = BETA2 * tmp->_adamAvgVelbias + (1 - BETA2) * tmp->_tbias * tmp->_tbias; - tmp->_bias += ratio*tmplr * tmp->_adamAvgMombias / (sqrt(tmp->_adamAvgVelbias) + EPS); + *tmp->_bias += ratio*tmplr * tmp->_adamAvgMombias / (sqrt(tmp->_adamAvgVelbias) + EPS); tmp->_tbias = 0; } else { std::copy(tmp->_mirrorWeights, tmp->_mirrorWeights+(tmp->_dim) , tmp->_weights); - tmp->_bias = tmp->_mirrorbias; + *tmp->_bias = tmp->_mirrorbias; } if (tmpRehash) { int *hashes; diff --git a/SLIDE/Node.cpp b/SLIDE/Node.cpp index 5fd055c..158b6c9 100755 --- a/SLIDE/Node.cpp +++ b/SLIDE/Node.cpp @@ -30,12 +30,12 @@ Node::Node(int dim, int nodeID, int layerID, NodeType type, int batchsize, float _activeInputs = 0; _weights = weights; - _bias = bias; - _mirrorbias = _bias; + //_bias = bias; + //_mirrorbias = _bias; } -void Node::Update(int dim, int nodeID, int layerID, NodeType type, int batchsize, float *weights, float bias, float *adamAvgMom, float *adamAvgVel, train* train_blob) +void Node::Update(int dim, int nodeID, int layerID, NodeType type, int batchsize, float *weights, float &bias, float *adamAvgMom, float *adamAvgVel, train* train_blob) { _dim = dim; _IDinLayer = nodeID; @@ -55,8 +55,8 @@ void Node::Update(int dim, int nodeID, int layerID, NodeType type, int batchsize _activeInputs = 0; _weights = weights; - _bias = bias; - _mirrorbias = _bias; + _bias = &bias; + _mirrorbias = *_bias; } @@ -100,7 +100,7 @@ float Node::getActivation(int* indices, float* values, int length, int inputID) { _train[inputID]._lastActivations += _weights[indices[i]] * values[i]; } - _train[inputID]._lastActivations += _bias; + _train[inputID]._lastActivations += (*_bias); switch (_type) { diff --git a/SLIDE/Node.h b/SLIDE/Node.h index ca592a0..ed80214 100755 --- a/SLIDE/Node.h +++ b/SLIDE/Node.h @@ -81,7 +81,7 @@ class Node float* _adamAvgVel; float* _t; //for adam int* _update; - float _bias =0; + float *_bias = NULL; float _tbias = 0; float _adamAvgMombias=0; float _adamAvgVelbias=0; @@ -89,7 +89,7 @@ class Node Node(){}; Node(int dim, int nodeID, int layerID, NodeType type, int batchsize, float *weights, float bias, float *adamAvgMom, float *adamAvgVel); - void Update(int dim, int nodeID, int layerID, NodeType type, int batchsize, float *weights, float bias, float *adamAvgMom, float *adamAvgVel, train* train_blob); + void Update(int dim, int nodeID, int layerID, NodeType type, int batchsize, float *weights, float &bias, float *adamAvgMom, float *adamAvgVel, train* train_blob); void updateWeights(float* newWeights, float newbias); float getLastActivation(int inputID); void incrementDelta(int inputID, float incrementValue);