当前位置: 首页>>代码示例>>Java>>正文


Java Inference类代码示例

本文整理汇总了Java中org.numenta.nupic.network.Inference的典型用法代码示例。如果您正苦于以下问题:Java Inference类的具体用法?Java Inference怎么用?Java Inference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Inference类属于org.numenta.nupic.network包,在下文中一共展示了Inference类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processInput

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
protected void processInput(Network network, IN record, long timestamp) throws Exception {

        if(userFunction.reset(record)) {
            network.reset();
            LOG.debug("network reset");
        }

        Object input = convertToInput(record, timestamp);
        Inference inference = network.computeImmediate(input);

        if(inference != null) {
            NetworkInference outputInference = NetworkInference.fromInference(inference);
            StreamRecord<Tuple2<IN,NetworkInference>> streamRecord = new StreamRecord<>(
                    new Tuple2<>(record, outputInference),
                    timestamp);
            output.collect(streamRecord);
        }
    }
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:19,代码来源:AbstractHTMInferenceOperator.java

示例2: listenToNetwork

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void listenToNetwork(Network network) {
    if(network == null) {
        throw new IllegalArgumentException("Cannot listen to null Network.");
    }
    
    this.htmNetwork = network;
    
    network.observe().subscribe(new Subscriber<Inference>() {
        @Override public void onCompleted() {}
        @Override public void onError(Throwable e) {}
        @Override public void onNext(Inference t) {
            currentPrediction = subsample(
                SDR.cellsAsColumnIndices(t.getPredictiveCells(), cellsPerColumn));
            semaphore.release();
        }
    });
    
    this.cellsPerColumn = htmNetwork.getHead().getTail().getConnections().getCellsPerColumn();
   
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:25,代码来源:StrictHackathonAlgorithm.java

示例3: fromInference

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
public static NetworkInference fromInference(Inference i) {
    Map<String, Classification<Object>> classifications = new HashMap<>();
    for (String field : i.getClassifiers().keys()) {
        classifications.put(field, i.getClassification(field));
    }
    return new NetworkInference(i.getAnomalyScore(), classifications);
}
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:8,代码来源:NetworkInference.java

示例4: writeToFile

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
/**
 * Primitive file appender for collecting output. This just demonstrates how to use
 * {@link Subscriber#onNext(Object)} to accomplish some work.
 *
 * @param infer             The {@link Inference} object produced by the Network
 * @param classifierField   The field we use in this demo for anomaly computing.
 */
private void writeToFile(Inference infer, String classifierField) {
    try {
        double newPrediction;
        if(null != infer.getClassification(classifierField).getMostProbableValue(1)) {
            newPrediction = (Double)infer.getClassification(classifierField).getMostProbableValue(1);
        } else {
            newPrediction = predictedValue;
        }
        if(infer.getRecordNum() > 0) {
            double actual = (Double)infer.getClassifierInput()
                    .get(classifierField).get("inputValue");
            double error = Math.abs(predictedValue - actual);
            StringBuilder sb = new StringBuilder()
                    .append(infer.getRecordNum()).append(", ")
                            //.append("classifier input=")
                    .append(String.format("%3.2f", actual)).append(", ")
                            //.append("prediction= ")
                    .append(String.format("%3.2f", predictedValue)).append(", ")
                    .append(String.format("%3.2f", error)).append(", ")
                            //.append("anomaly score=")
                    .append(infer.getAnomalyScore());
            pw.println(sb.toString());
            pw.flush();
            System.out.println(sb.toString());
        } else {

        }
        predictedValue = newPrediction;
    }catch(Exception e) {
        e.printStackTrace();
        pw.flush();
    }

}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:42,代码来源:NetworkAPIDemo.java

示例5: testSerializeDeSerialize

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
@Test
public void testSerializeDeSerialize() {
    final List<Inference> callVerify = new ArrayList<>();
    
    SerializerCore serializer = Persistence.get().serializer();
    
    Inference inf = new ManualInput() {
        @SuppressWarnings("unchecked")
        @Override
        public <T> T postDeSerialize(T i) {
            Inference retVal = (Inference)super.postDeSerialize(i);
            assertNotNull(retVal);
            assertTrue(retVal != i); // Ensure Objects not same
            assertTrue(retVal.equals(i)); // However they are still equal!
            callVerify.add(retVal);
            assertTrue(callVerify.size() == 1);
            
            return (T)retVal;
        }
    };
    
    byte[] bytes = serializer.serialize(inf);
    assertNotNull(bytes);
    
    Inference serializedInf = serializer.deSerialize(bytes);
    assertNotNull(serializedInf);
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:28,代码来源:SerializerCoreTest.java

示例6: testGetSubscriber

import org.numenta.nupic.network.Inference; //导入依赖的package包/类
@Test
public void testGetSubscriber() {
    NetworkAPIDemo demo = new NetworkAPIDemo(Mode.MULTIREGION);
    Subscriber<Inference> s = demo.getSubscriber();
    assertNotNull(s);
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:7,代码来源:NetworkAPIDemoTest.java


注:本文中的org.numenta.nupic.network.Inference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。