| 2045 | } |
| 2046 | |
| 2047 | void Layer::reduceIndexFromAllMaps( unsigned startIndex ) |
| 2048 | { |
| 2049 | // Adjust the source layers |
| 2050 | Map<unsigned, unsigned> copyOfSources = _sourceLayers; |
| 2051 | _sourceLayers.clear(); |
| 2052 | for ( const auto &pair : copyOfSources ) |
| 2053 | _sourceLayers[pair.first >= startIndex ? pair.first - 1 : pair.first] = pair.second; |
| 2054 | |
| 2055 | // Adjust all weight maps |
| 2056 | adjustWeightMapIndexing( _layerToWeights, startIndex ); |
| 2057 | adjustWeightMapIndexing( _layerToPositiveWeights, startIndex ); |
| 2058 | adjustWeightMapIndexing( _layerToNegativeWeights, startIndex ); |
| 2059 | |
| 2060 | // Adjust the neuron activations |
| 2061 | for ( auto &neuronToSources : _neuronToActivationSources ) |
| 2062 | { |
| 2063 | for ( auto &source : neuronToSources.second ) |
| 2064 | { |
| 2065 | if ( source._layer >= startIndex ) |
| 2066 | --source._layer; |
| 2067 | } |
| 2068 | } |
| 2069 | } |
| 2070 | |
| 2071 | void Layer::adjustWeightMapIndexing( Map<unsigned, double *> &map, unsigned startIndex ) |
| 2072 | { |