Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* ---------------------------------------------------------------------
* Numenta Platform for Intelligent Computing (NuPIC)
* Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
* with Numenta, Inc., for a separate license for this software code, the
* following terms and conditions apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License version 3 as
* published by the Free Software Foundation.
*
* This program 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 Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with this program. If not, see http://www.gnu.org/licenses.
*
* http://numenta.org/licenses/
* ---------------------------------------------------------------------
*/
package org.numenta.nupic.algorithms;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.numenta.nupic.model.Persistable;
import org.numenta.nupic.util.ArrayUtils;
import org.numenta.nupic.util.Deque;
import org.numenta.nupic.util.Tuple;
import gnu.trove.list.TIntList;
import gnu.trove.list.array.TIntArrayList;
/**
* A CLA classifier accepts a binary input from the level below (the
* "activationPattern") and information from the sensor and encoders (the
* "classification") describing the input to the system at that time step.
*
* When learning, for every bit in activation pattern, it records a history of the
* classification each time that bit was active. The history is weighted so that
* more recent activity has a bigger impact than older activity. The alpha
* parameter controls this weighting.
*
* For inference, it takes an ensemble approach. For every active bit in the
* activationPattern, it looks up the most likely classification(s) from the
* history stored for that bit and then votes across these to get the resulting
* classification(s).
*
* This classifier can learn and infer a number of simultaneous classifications
* at once, each representing a shift of a different number of time steps. For
* example, say you are doing multi-step prediction and want the predictions for
* 1 and 3 time steps in advance. The CLAClassifier would learn the associations
* between the activation pattern for time step T and the classifications for
* time step T+1, as well as the associations between activation pattern T and
* the classifications for T+3. The 'steps' constructor argument specifies the
* list of time-steps you want.
*
* @author Numenta
* @author David Ray
* @see BitHistory
*/
public class CLAClassifier implements Persistable, Classifier {
private static final long serialVersionUID = 1L;
int verbosity = 0;
/**
* The alpha used to compute running averages of the bucket duty
* cycles for each activation pattern bit. A lower alpha results
* in longer term memory.
*/
double alpha = 0.001;
double actValueAlpha = 0.3;
/**
* The bit's learning iteration. This is updated each time store() gets
* called on this bit.
*/
int learnIteration;
/**
* This contains the offset between the recordNum (provided by caller) and
* learnIteration (internal only, always starts at 0).
*/
int recordNumMinusLearnIteration = -1;
/**
* This contains the value of the highest bucket index we've ever seen
* It is used to pre-allocate fixed size arrays that hold the weights of
* each bucket index during inference
*/
int maxBucketIdx;
/** The sequence different steps of multi-step predictions */
TIntList steps = new TIntArrayList();
/**
* History of the last _maxSteps activation patterns. We need to keep
* these so that we can associate the current iteration's classification
* with the activationPattern from N steps ago
*/
Deque patternNZHistory;
/**
* These are the bit histories. Each one is a BitHistory instance, stored in
* this dict, where the key is (bit, nSteps). The 'bit' is the index of the
* bit in the activation pattern and nSteps is the number of steps of
* prediction desired for that bit.
*/
Map activeBitHistory = new HashMap();
/**
* This keeps track of the actual value to use for each bucket index. We
* start with 1 bucket, no actual value so that the first infer has something
* to return
*/
List> actualValues = new ArrayList