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


Java Network类代码示例

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


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

示例1: processInput

import org.numenta.nupic.network.Network; //导入依赖的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: initInputFunction

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Initialize the input function to map input elements to HTM encoder input.
 * @throws Exception
 */
protected void initInputFunction() throws Exception {

    // it is premature to call getInputNetwork, because no 'key' is available
    // when the operator is first opened.
    Network network = networkFactory.createNetwork(null);
    MultiEncoder encoder = network.getEncoder();

    if(encoder == null)
        throw new IllegalArgumentException("a network encoder must be provided");

    // handle the situation where an encoder parameter map was supplied rather than a fully-baked encoder.
    if(encoder.getEncoders(encoder) == null || encoder.getEncoders(encoder).size() < 1) {
        Map<String, Map<String, Object>> encoderParams =
                (Map<String, Map<String, Object>>) network.getParameters().get(Parameters.KEY.FIELD_ENCODING_MAP);
        if(encoderParams == null || encoderParams.size() < 1) {
            throw new IllegalStateException("No field encoding map found for MultiEncoder");
        }
        encoder.addMultipleEncoders(encoderParams);
    }

    // generate the encoder input function
    final GenerateEncoderInputFunction<IN> generator = new GenerateEncoderInputFunction<>((CompositeType<IN>) inputType, encoder, executionConfig);
    inputFunction = generator.generate();
}
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:29,代码来源:AbstractHTMInferenceOperator.java

示例3: createNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
@Override
public Network createNetwork(Object key) {
    Parameters p = getParameters();
    p = p.union(getEncoderParams());
    p.set(Parameters.KEY.COLUMN_DIMENSIONS, new int[] { 30 });
    p.set(Parameters.KEY.SYN_PERM_INACTIVE_DEC, 0.1);
    p.set(Parameters.KEY.SYN_PERM_ACTIVE_INC, 0.1);
    p.set(Parameters.KEY.SYN_PERM_TRIM_THRESHOLD, 0.05);
    p.set(Parameters.KEY.SYN_PERM_CONNECTED, 0.4);
    p.set(Parameters.KEY.MAX_BOOST, 10.0);
    p.set(Parameters.KEY.DUTY_CYCLE_PERIOD, 7);
    p.set(Parameters.KEY.RANDOM, new MersenneTwister(42));

    Map<String, Object> params = new HashMap<>();
    params.put(KEY_MODE, Anomaly.Mode.PURE);

    Network n = Network.create("DayDemoNetwork", p)
            .add(Network.createRegion("r1")
                    .add(Network.createLayer("1", p)
                            .alterParameter(Parameters.KEY.AUTO_CLASSIFY, Boolean.TRUE)
                            .alterParameter(Parameters.KEY.INFERRED_FIELDS, getInferredFieldsMaps())
                            .add(new TemporalMemory())
                            .add(new SpatialPooler())
                            .add(MultiEncoder.builder().name("").build())));
    return n;
}
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:27,代码来源:TestHarness.java

示例4: feedNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Feeds the specified {@link Network} with the contents of the specified
 * {@link Iterator}
 * @param network   the current {@link Network} object
 * @param it        an {@link Iterator} over the input source file lines
 * @return
 */
String[] feedNetwork(Network network, Iterator<String[]> it) {
    (new Thread() {
        public void run() {
            for(;it.hasNext();) {
                String[] next = it.next();

                if(!it.hasNext()) {
                    phraseEndedProperty.set(next);
                    finalResult = next;
                    break;
                }else{
                    phraseEntryProperty.set(next);
                }

                feedLine(network, next);
            }

            Platform.runLater(() -> { callback.call(finalResult); });
        }
    }).start();

    return null;
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:31,代码来源:FoxEatsDemo.java

示例5: feedNetworkForTest

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * <em>WARNING:</em> For test only!
 *
 * Runs same method as {@link #feedNetwork(Network, Iterator)} without
 * threading.
 *
 * Feeds the specified {@link Network} with the contents of the specified
 * {@link Iterator}
 * @param network   the current {@link Network} object
 * @param it        an {@link Iterator} over the input source file lines
 * @return
 */
String[] feedNetworkForTest(Network network, Iterator<String[]> it) {
    for(;it.hasNext();) {
        String[] next = it.next();

        phraseEntryProperty.set(next);

        if(!it.hasNext()) {
            phraseEndedProperty.set(next);
            finalResult = next;
            break;
        }

        feedLine(network, next);
    }

    return finalResult;
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:30,代码来源:FoxEatsDemo.java

示例6: StrictHackathonAlgorithm

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Constructs a new {@code StrictHackathonAlgorithm}
 * 
 * @param client
 * @param htmNetwork
 */
public StrictHackathonAlgorithm(FullClient client, Network htmNetwork) {
    this.client = client;
    this.htmNetwork = htmNetwork;
    
    processedTweets = new ArrayList<>();
    anomalousTweets = new ArrayList<>();
    highSimilarityTweets = new ArrayList<>();
    
    semaphore = new Semaphore(1, false);
    
    rng = new Random();
    
    if(htmNetwork != null) {
        listenToNetwork(htmNetwork);
    }
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:23,代码来源:StrictHackathonAlgorithm.java

示例7: listenToNetwork

import org.numenta.nupic.network.Network; //导入依赖的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

示例8: createBasicNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Creates a basic {@link Network} with 1 {@link Region} and 1 {@link Layer}. However
 * this basic network contains all algorithmic components.
 *
 * @return  a basic Network
 */
Network createBasicNetwork() {
    Parameters p = NetworkDemoHarness.getParameters();
    p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());

    // This is how easy it is to create a full running Network!
    return Network.create("Network API Demo", p)
        .add(Network.createRegion("Region 1")
            .add(Network.createLayer("Layer 2/3", p)
                .alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)
                .add(Anomaly.create())
                .add(new TemporalMemory())
                .add(new SpatialPooler())
                .add(Sensor.create(FileSensor::create, SensorParams.create(
                    Keys::path, "", ResourceLocator.path("rec-center-hourly.csv"))))));
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:22,代码来源:NetworkAPIDemo.java

示例9: createMultiLayerNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Creates a {@link Network} containing one {@link Region} with multiple
 * {@link Layer}s. This demonstrates the method by which multiple layers
 * are added and connected; and the flexibility of the fluent style api.
 *
 * @return  a multi-layer Network
 */
Network createMultiLayerNetwork() {
    Parameters p = NetworkDemoHarness.getParameters();
    p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());

    return Network.create("Network API Demo", p)
        .add(Network.createRegion("Region 1")
            .add(Network.createLayer("Layer 2/3", p)
                .alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)
                .add(Anomaly.create())
                .add(new TemporalMemory()))
            .add(Network.createLayer("Layer 4", p)
                .add(new SpatialPooler()))
            .add(Network.createLayer("Layer 5", p)
                .add(Sensor.create(FileSensor::create, SensorParams.create(
                    Keys::path, "", ResourceLocator.path("rec-center-hourly.csv")))))
            .connect("Layer 2/3", "Layer 4")
            .connect("Layer 4", "Layer 5"));
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:26,代码来源:NetworkAPIDemo.java

示例10: getLoadedHotGymNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
private Network getLoadedHotGymNetwork() {
    Parameters p = NetworkTestHarness.getParameters().copy();
    p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
    p.set(KEY.RANDOM, new FastRandom(42));
    p.set(KEY.INFERRED_FIELDS, getInferredFieldsMap("consumption", CLAClassifier.class));

    Sensor<ObservableSensor<String[]>> sensor = Sensor.create(
        ObservableSensor::create, SensorParams.create(Keys::obs, new Object[] {"name", 
            PublisherSupplier.builder()
            .addHeader("timestamp, consumption")
            .addHeader("datetime, float")
            .addHeader("B").build() }));

    Network network = Network.create("test network", p).add(Network.createRegion("r1")
        .add(Network.createLayer("1", p)
            .alterParameter(KEY.AUTO_CLASSIFY, true)
            .add(Anomaly.create())
            .add(new TemporalMemory())
            .add(new SpatialPooler())
            .add(sensor)));

    return network;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:24,代码来源:HTMObjectInputOutputTest.java

示例11: open

import org.numenta.nupic.network.Network; //导入依赖的package包/类
@Override
public void open() throws Exception {
    super.open();

    if (networkState == null) {
        networkState = getPartitionedState(new ValueStateDescriptor<Network>(
                HTM_INFERENCE_OPERATOR_STATE_NAME,
                new KryoSerializer<Network>((Class<Network>) (Class<?>) Network.class, getExecutionConfig())
        ));
    }

    initInputFunction();
}
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:14,代码来源:KeyedHTMInferenceOperator.java

示例12: getInputNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
@Override
protected Network getInputNetwork() throws Exception {
    Network network = networkState.value();
    if(network == null) {
        network = networkFactory.createNetwork(null);
        networkState.update(network);

        networkCounter.add(1);
        LOG.info("Created HTM network {}", network.getName());
    }
    return network;
}
 
开发者ID:htm-community,项目名称:flink-htm,代码行数:13,代码来源:KeyedHTMInferenceOperator.java

示例13: startNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
private void startNetwork() {
    demo.setDataFilePath("foxeat.csv");
    demo.setInputData(demo.readInputData("foxeat.csv"));
    
    demo.loadCache();
    
    // Test api connection by executing dummy query
    boolean success = demo.connectionValid(apiKey);
    if(!success) {
        throw new RuntimeException(new ApiException());
    }

    // Create the Network
    Network network = demo.createNetwork();

    // Returns the last line of the file which is has the question terms: "fox, eats, <something>"
    demo.feedNetwork(network, demo.inputIterator());
    
    demo.setCallBack((sa) -> {
        Platform.runLater(() -> {
            // Returns the Term for the answer to what a fox eats.
            Term answer = demo.feedQuestion(network, sa);
            
            // Print it to standard out. (For now...)
            lArea.appendText("\t\t\t\t\t\tAnswer: \t" + answer.getTerm());
            
            // Cache fingerprints
            demo.writeCache();
        });
        return null;
    });
    
    
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:35,代码来源:FoxEatsDemoView.java

示例14: createNetwork

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Creates and returns a {@link Network} for demo processing
 * @return
 */
Network createNetwork() {
    org.numenta.nupic.Parameters temporalParams = createParameters();
    network = Network.create("Cortical.io API Demo", temporalParams)
        .add(Network.createRegion("Region 1")
            .add(Network.createLayer("Layer 2/3", temporalParams)
                .add(new TemporalMemory())));
    return network;
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:13,代码来源:FoxEatsDemo.java

示例15: feedLine

import org.numenta.nupic.network.Network; //导入依赖的package包/类
/**
 * Feeds a single array of phrase words into the {@link Network}.
 *
 * @param network
 * @param phrase
 */
void feedLine(Network network, String[] phrase) {
    for(String term : phrase) {
        int[] sdr = getFingerprintSDR(term);
        network.compute(sdr);
    }

    network.reset();
}
 
开发者ID:numenta,项目名称:htm.java-examples,代码行数:15,代码来源:FoxEatsDemo.java


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