def main(): """ """ import random import numpy model = createModel() shifter = InferenceShifter() tobological_data, label = load_dataset( './data/pylearn2_gcn_whitened/train.pkl') for i, data in enumerate(tobological_data[:1000]): if label[i][0] not in (0, 1): continue patch_data, movement = get_patch(data, height=patch_heigh, width=patch_width, step=patch_step) print '%d, label:%s, ' % (i, label[i][0]), for data in patch_data: input_len = reduce(lambda x, y: x * y, data.shape) input_data = { 'pixel': data.reshape((input_len)).tolist(), 'label': label[i][0] } model.enableLearning() result = model.run(input_data) #result = shifter.shift(result) print label[i][0], result.inferences['multiStepBestPredictions'] #model.resetSequenceStates() #model._getTPRegion().executeCommand(['resetSequenceStates']) #model._getTPRegion().resetSequenceStates() model._getTPRegion().getSelf().resetSequenceStates() # validate if i % 3 == 0: valid = validate(model, test_data, test_label, limit=30) print '%d : valid: %8.5f' % (i, valid)
def main(): """ """ import random import numpy model = createModel() shifter = InferenceShifter() tobological_data, label = load_dataset('./data/pylearn2_gcn_whitened/train.pkl') for i, data in enumerate(tobological_data[:1000]): if label[i][0] not in (0, 1): continue patch_data, movement = get_patch(data, height=patch_heigh, width=patch_width, step=patch_step) print '%d, label:%s, ' % (i, label[i][0]), for data in patch_data: input_len = reduce(lambda x,y: x * y, data.shape) input_data = { 'pixel': data.reshape((input_len)).tolist() , 'label': label[i][0] } model.enableLearning() result = model.run(input_data) #result = shifter.shift(result) print label[i][0], result.inferences['multiStepBestPredictions'] #model.resetSequenceStates() #model._getTPRegion().executeCommand(['resetSequenceStates']) #model._getTPRegion().resetSequenceStates() model._getTPRegion().getSelf().resetSequenceStates() # validate if i % 3 == 0: valid = validate(model, test_data, test_label, limit=30) print '%d : valid: %8.5f' % (i, valid)
# /usr/bin/python # coding: utf-8 from pprint import pprint from pylab import * from collections import defaultdict, Counter from nupic_dir.lib.cla_classifier import ClaClassifier from nupic_dir.lib.function_data import function_data from nupic_dir.lib.plotter import Plotter from nupic_dir.lib.create_network import net_structure, sensor_params, dest_resgion_data, class_encoder_params from nupic_dir.lib.load_data import load_dataset, get_patch test_data, test_label = load_dataset("./data/pylearn2_gcn_whitened/test.pkl") train_data, train_label = load_dataset("./data/pylearn2_gcn_whitened/train.pkl") patch_heigh = 32 patch_width = 32 patch_step = 32 def validate(recogniter, test_data, test_label, limit=100): result = [] tdata = test_data[:limit] for i, data in enumerate(tdata): patch_result = Counter() patch_data, movement = get_patch(data, height=patch_heigh, width=patch_width, step=patch_step) for patch in patch_data: input_len = reduce(lambda x, y: x * y, patch.shape) input_data = {"pixel": patch.reshape((input_len)).tolist(), "label": "no"}
#/usr/bin/python # coding: utf-8 from pprint import pprint from pylab import * from collections import defaultdict, Counter from nupic_dir.lib.cla_classifier import ClaClassifier from nupic_dir.lib.function_data import function_data from nupic_dir.lib.plotter import Plotter from nupic_dir.lib.create_network import net_structure, sensor_params, dest_resgion_data, class_encoder_params from nupic_dir.lib.load_data import load_dataset, get_patch test_data, test_label = load_dataset('./data/pylearn2_gcn_whitened/test.pkl') train_data, train_label = load_dataset( './data/pylearn2_gcn_whitened/train.pkl') patch_heigh = 32 patch_width = 32 patch_step = 32 def validate(recogniter, test_data, test_label, limit=100): result = [] tdata = test_data[:limit] for i, data in enumerate(tdata): patch_result = Counter() patch_data, movement = get_patch(data, height=patch_heigh, width=patch_width, step=patch_step)