Skip to content

Instantly share code, notes, and snippets.

@sotelo
Created May 18, 2015 15:45
Show Gist options
  • Save sotelo/29cb3b043c4c9a734ad7 to your computer and use it in GitHub Desktop.
Save sotelo/29cb3b043c4c9a734ad7 to your computer and use it in GitHub Desktop.
Different behaviour in gpu and cpu.
import theano
import numpy
from collections import OrderedDict
from fuel.datasets import IndexableDataset
from fuel.streams import DataStream
from fuel.schemes import SequentialScheme
from theano import tensor
from blocks.monitoring.evaluators import DatasetEvaluator
from blocks.monitoring.aggregation import Mean
num_examples = 5
num_batches = 3
batch_size = 2
features = numpy.array([[3, 3],
[2, 9],
[2, 4],
[5, 1],
[3, 3]], dtype=theano.config.floatX)
print -features.mean(axis = 0)
#[-3. -4.]
dataset = IndexableDataset(OrderedDict([('features', features)]))
x = tensor.matrix('features')
y = -x
y.name = 'y'
y.tag.aggregation_scheme = Mean(y.sum(axis=0), y.shape[0])
data_stream_2 = DataStream(dataset,
iteration_scheme=SequentialScheme(num_examples, 2))
print DatasetEvaluator([y]).evaluate(data_stream_2)['y']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment