rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if not (type(outputs_info) in (list,tuple)): | if not (type(outputs_info) in (list,tuple)) and outputs_info != None: | def scan( fn , sequences = None , outputs_info = None , non_sequences = None , n_steps = None , truncate_gradient = -1 , go_backwards = False , mode = None , name = None ): """ This function constructs and applies a Scan op to the provided arguments. :param fn:... |
if not (type(non_sequences) in (list,tuple)): | if ( not (type(non_sequences) in (list,tuple)) and non_sequences != None): | def scan( fn , sequences = None , outputs_info = None , non_sequences = None , n_steps = None , truncate_gradient = -1 , go_backwards = False , mode = None , name = None ): """ This function constructs and applies a Scan op to the provided arguments. :param fn:... |
return (3,) + self.build_gemm_version() | gv = self.build_gemm_version() if gv: return (3,) + gv else: return gv | def c_code_cache_version(self): return (3,) + self.build_gemm_version() |
return (1,) + self.build_gemm_version() | gv = self.build_gemm_version() if gv: return (1,) + gv else: return gv | def c_code_cache_version(self): return (1,) + self.build_gemm_version() |
return (2,) + self.build_gemm_version() | gv = self.build_gemm_version() if gv: return (2,) + gv else: return gv | def c_code_cache_version(self): return (2,) + self.build_gemm_version() |
npy_intp* Nz = 0; //%(_z)s->dimensions; | npy_intp* Nz = 0; //%(_zout)s->dimensions; | def c_compile_args(self): return ldflags(libs=False, flags=True) |
npy_intp* Sz = 0; //%(_z)s->strides; | npy_intp* Sz = 0; //%(_zout)s->strides; | def c_compile_args(self): return ldflags(libs=False, flags=True) |
if (%(_z)s->nd != 2) {PyErr_SetString(PyExc_NotImplementedError, "rank(z) != 2"); %(fail)s;} | if (%(_zout)s->nd != 2) {PyErr_SetString(PyExc_NotImplementedError, "rank(z) != 2"); %(fail)s;} | def c_compile_args(self): return ldflags(libs=False, flags=True) |
if ((%(_z)s->descr->type_num != PyArray_DOUBLE) && (%(_z)s->descr->type_num != PyArray_FLOAT)) | if ((%(_zout)s->descr->type_num != PyArray_DOUBLE) && (%(_zout)s->descr->type_num != PyArray_FLOAT)) | def c_compile_args(self): return ldflags(libs=False, flags=True) |
||(%(_x)s->descr->type_num != %(_z)s->descr->type_num)) | ||(%(_x)s->descr->type_num != %(_zout)s->descr->type_num)) | def c_compile_args(self): return ldflags(libs=False, flags=True) |
encode the stride structure of _x,_y,_z into a single integer | encode the stride structure of _x,_y,_zout into a single integer | def c_compile_args(self): return ldflags(libs=False, flags=True) |
float* z = (float*)PyArray_DATA(%(_z)s); | float* z = (float*)PyArray_DATA(%(_zout)s); | def c_compile_args(self): return ldflags(libs=False, flags=True) |
double* z = (double*)PyArray_DATA(%(_z)s); | double* z = (double*)PyArray_DATA(%(_zout)s); | def c_compile_args(self): return ldflags(libs=False, flags=True) |
if (NULL != %(_zout)s) Py_XDECREF(%(_zout)s); | if (%(_zout)s) Py_XDECREF(%(_zout)s); | def perform(self, node, (z, a, x, y, b), (zout, )): assert a.shape == () assert b.shape == () if not self.inplace: z = z.copy() # the original z will not be changed if z.shape == (): z.itemset(z*a + b*numpy.dot(x,y)) zout[0] = z else: if b == 0.0: if a == 1.0: z[:] = numpy.dot(x,y) elif a == -1.0: z[:] = -numpy.dot(x,y... |
return (2,) + self.build_gemm_version() | return (3,) + self.build_gemm_version() | def c_code_cache_version(self): return (2,) + self.build_gemm_version() |
if ((NULL == %(_z)s) || (%(_z)s->dimensions[0] != %(_x)s->dimensions[0]) || (%(_z)s->dimensions[1] != %(_y)s->dimensions[1])) | if ((NULL == %(_zout)s) || (%(_zout)s->dimensions[0] != %(_x)s->dimensions[0]) || (%(_zout)s->dimensions[1] != %(_y)s->dimensions[1])) | def __str__(self): return "_dot22" |
if (NULL != %(_z)s) Py_XDECREF(%(_z)s); | if (NULL != %(_zout)s) Py_XDECREF(%(_zout)s); | def __str__(self): return "_dot22" |
%(_z)s = (PyArrayObject*)PyArray_SimpleNew(2, dims, type_num_%(_x)s); if(!%(_z)s) { | %(_zout)s = (PyArrayObject*)PyArray_SimpleNew(2, dims, type_num_%(_x)s); if(!%(_zout)s) { | def __str__(self): return "_dot22" |
Nz = %(_z)s->dimensions; Sz = %(_z)s->strides; | Nz = %(_zout)s->dimensions; Sz = %(_zout)s->strides; | def __str__(self): return "_dot22" |
def c_code(self, node, name, (_x, _y), (_z, ), sub): | def c_code(self, node, name, (_x, _y), (_zout, ), sub): | def c_code(self, node, name, (_x, _y), (_z, ), sub): #DEBUG if len(self.c_libraries())<=0: return super(Dot22, self).c_code(node, name, (_x, _y), (_z, ), sub) full_code = self.build_gemm_call() % dict(locals(), **sub) return full_code |
return super(Dot22, self).c_code(node, name, (_x, _y), (_z, ), sub) | return super(Dot22, self).c_code(node, name, (_x, _y), (_zout, ), sub) | def c_code(self, node, name, (_x, _y), (_z, ), sub): #DEBUG if len(self.c_libraries())<=0: return super(Dot22, self).c_code(node, name, (_x, _y), (_z, ), sub) full_code = self.build_gemm_call() % dict(locals(), **sub) return full_code |
}; """ operator_eq = """ template <> %(mytype)s & %(mytype)s::operator=<npy_int8>(const npy_int8 & y) { this->real=y; this->imag=0; return *this; } template <> %(mytype)s & %(mytype)s::operator=<npy_int16>(const npy_int16 & y) { this->real=y; this->imag=0; return *this; } template <> %(mytype)s & %(mytype)s::operato... | }; | typedef npy_float%(half_nbits)s scalar_type; |
def operator_eq_real(mytype, othertype): return ''' template <> %(mytype)s & %(mytype)s::operator=<%(othertype)s>(const %(othertype)s & y) { this->real=y; this->imag=0; return *this; } ''' % dict(mytype = mytype, othertype = othertype) def operator_eq_cplx(mytype, othertype): return ''' template <> %(mytype)s & %(myty... | typedef npy_float%(half_nbits)s scalar_type; | |
+ operator_eq % dict(mytype='theano_complex128') \ + operator_eq % dict(mytype='theano_complex64') else: | + operator_eq \ + operator_plus \ + operator_minus \ + operator_mul else: | typedef npy_float%(half_nbits)s scalar_type; |
cuda_path='/u/bastienf/repos/theano/sandbox/cuda' | cuda_path=os.path.split(old_file)[0] | def debug(*msg): _logger.debug(_logger_name+'DEBUG: '+' '.join(str(m) for m in msg)) |
assert nb_failed==0 | assert nb_failed==0, nb_failed | def exec_conv(version, shapes, verbose, random, mode, print_=None, rtol=1e-5, ones=False): if verbose>0: _params_allgood_header() nb_failed = 0 nb_tests = 0 failed_version=set() failed_id=[] for ver in version:# I put -1 in case we forget to add version in the test to. for id,(ishape, kshape, subshape, istride, kstrid... |
self.failUnless(isinstance(g, TensorConstant)) self.failUnless(g.data == 0) | self.failUnless(g.owner.op == fill) self.failUnless(g.owner.inputs[1].data == 0) | def test_1None_rval(self): """grad: Test returning a single None from grad""" o = test_grad.O() a1 = o.make_node() g = grad(a1.outputs[0], a1.outputs[1]) self.failUnless(isinstance(g, TensorConstant)) self.failUnless(g.data == 0) try: grad(a1.outputs[0], 'wtf') except AttributeError, e: return self.fail() |
self.failUnless(isinstance(g2, TensorConstant)) self.failUnless(g2.data == 0) | self.failUnless(g2.owner.op == fill) self.failUnless(g2.owner.inputs[1].data == 0) | def test_NNone_rval(self): """grad: Test returning some Nones from grad""" o = test_grad.O() a1 = o.make_node() g0,g1,g2 = grad(a1.outputs[0], a1.inputs + [scalar('z')]) self.failUnless(o.gval0 is g0) self.failUnless(o.gval1 is g1) self.failUnless(isinstance(g2, TensorConstant)) self.failUnless(g2.data == 0) |
if imshp is None: | if imshp is None or any([x is None for x in imshp]): | def perform(self,node, (img2d, filtersflipped), (z,)): """ By default if len(img2d.shape)==3, we """ # TODO: move these back out to global scope when they no longer cause an atexit error from scipy.signal.signaltools import _valfrommode, _bvalfromboundary from scipy.signal.sigtools import _convolve2d imshp = self.imsh... |
if kshp is None: | if kshp is None or any([x is None for x in kshp]): | def perform(self,node, (img2d, filtersflipped), (z,)): """ By default if len(img2d.shape)==3, we """ # TODO: move these back out to global scope when they no longer cause an atexit error from scipy.signal.signaltools import _valfrommode, _bvalfromboundary from scipy.signal.sigtools import _convolve2d imshp = self.imsh... |
if numpy.any([x is None for x in kshp_logical]): kshp = tuple(filtersflipped.shape[2:]) | def perform(self,node, (img2d, filtersflipped), (z,)): """ By default if len(img2d.shape)==3, we """ # TODO: move these back out to global scope when they no longer cause an atexit error from scipy.signal.signaltools import _valfrommode, _bvalfromboundary from scipy.signal.sigtools import _convolve2d imshp = self.imsh... | |
if z[0] is None: | if z[0] is None or z[0].shape!=(bsize,)+(nkern,)+fulloutshp: | def perform(self,node, (img2d, filtersflipped), (z,)): """ By default if len(img2d.shape)==3, we """ # TODO: move these back out to global scope when they no longer cause an atexit error from scipy.signal.signaltools import _valfrommode, _bvalfromboundary from scipy.signal.sigtools import _convolve2d imshp = self.imsh... |
assert state.value == numpy_state | assert numpy.allclose(state.value, numpy_state) | def f_2(): return {state: 2*state} |
f = file('obj.save', 'wb') cPickle.dump(my_obj, f, protocol=cPickle.HIGHEST_PROTOCOL) f.close() f = file('obj.save', 'rb') loaded_obj = cPickle.load(f) f.close() obj1 = my_obj obj2 = my_obj obj3 = my_obj f = file('objects.save', 'wb') for obj in [obj1, obj2, obj3]: cPickle.dump(obj, f, protocol=cPickle.HIGHEST_PROT... | mode_instance = theano.compile.mode.get_mode(None) if not isinstance(mode_instance, theano.compile.debugmode.DebugMode): f = file('obj.save', 'wb') cPickle.dump(my_obj, f, protocol=cPickle.HIGHEST_PROTOCOL) f.close() f = file('obj.save', 'rb') loaded_obj = cPickle.load(f) f.close() obj1 = my_obj obj2 = my_obj obj3 =... | def test_loading_and_saving_1(self): |
warnings.warn("The default axis of min will change! Now we return the min over the last dimensions. It will change to be the same as numpy: the min over all dimensions. To hide this warning and be compatible with the future behavior, set axis to -1 to have the current behavior. To have the futur behavior set axis to ra... | warnings.warn("The default axis of min will change! Now we return the min over the last dimensions. It will change to be the same as numpy: the min over all dimensions. To hide this warning and be compatible with the future behavior, set axis to -1 to have the current behavior. To have the future behavior, set axis to ... | def min(x, axis='DEFAULT'): if x.type.ndim == 1 and axis in ('DEFAULT', None): # The old and new behavior are not different. axis = 0 elif axis=='DEFAULT': axis = x.type.ndim - 1 warnings.warn("The default axis of min will change! Now we return the min over the last dimensions. It will change to be the same as numpy: t... |
warnings.warn("The behavior of min when axis==None will change! Now we return the min over the last dimensions. It will change to the min over all dimensions as numpy. To hide this warning and be compatible with the future behavior, set axis to -1 to have the current behavior. To have the futur behavior set axis to ran... | warnings.warn("The behavior of min when axis is None will change! Now we return the min over the last dimensions. It will change to the min over all dimensions as numpy. To hide this warning and be compatible with the future behavior, set axis to -1 to have the current behavior. To have the future behavior, set axis to... | def min(x, axis='DEFAULT'): if x.type.ndim == 1 and axis in ('DEFAULT', None): # The old and new behavior are not different. axis = 0 elif axis=='DEFAULT': axis = x.type.ndim - 1 warnings.warn("The default axis of min will change! Now we return the min over the last dimensions. It will change to be the same as numpy: t... |
"""Compute the variance along the given axis of a tensor `input` :param axis: compute the variance along this axis of the tensor. None means trailing axis. | """Compute the variance along the given axis of a tensor `input`. :param axis: Compute the variance along this axis of the tensor. None means all axes (like numpy). | def var(input, axis = None): """Compute the variance along the given axis of a tensor `input` :param axis: compute the variance along this axis of the tensor. None means trailing axis. :type axis: None or int or (list of int) (see `Sum`) """ input_ndim = input.type.ndim if axis == None: axis = range(input_ndim) if i... |
sm_w_bias = local_softmax_with_bias.transform(sm) | sm_w_bias = local_softmax_with_bias.transform(sm.owner) | def local_advanced_indexing_crossentropy_onehot(node): log = None sm = None # First case: log(softmax(x))[rows, labels] if isinstance(node.op, tensor.AdvancedSubtensor): try: log, rows, labels = node.inputs except: pass if log and log.owner and log.owner.op == tensor.log: sm = log.owner.inputs[0] # Second case: log(so... |
set_instead_of_inc=incsubt.op.set_instead_of_inc)( | set_instead_of_inc=incsubt.set_instead_of_inc)( | def local_gpu_incsubtensor(node): if node.op == gpu_from_host: host_output = node.inputs[0] if host_output.owner and type(host_output.owner.op) == tensor.IncSubtensor: incsubt = host_output.owner.op x, y = host_output.owner.inputs[0:2] coords = host_output.owner.inputs[2:] return [GpuIncSubtensor(incsubt.idx_list, inpl... |
self.validate((3,7,5), (5,2,3), 'valid') self.validate((7,5), (5,2,3), 'valid') self.validate((3,7,5), (2,3), 'valid') self.validate((7,5), (2,3), 'valid') | self.validate((1,4,5), (2,2,3), verify_grad=True) self.validate((7,5), (5,2,3), verify_grad=False) self.validate((3,7,5), (2,3), verify_grad=False) self.validate((7,5), (2,3), verify_grad=False) | def test_basic(self): """ Basic functionality of nnet.conv.ConvOp is already tested by its own test suite. We just have to test whether or not signal.conv.conv2d can support inputs and filters of type matrix or tensor3. """ self.validate((3,7,5), (5,2,3), 'valid') self.validate((7,5), (5,2,3), 'valid') self.validate((... |
return (0,7) | return (0,8) | def c_code_cache_version(self): return (0,7) |
except ValueError: | except TypeError: | def test_elemwise_bad_broadcast(): x = cuda.fmatrix('x') y = cuda.fmatrix('y') f = theano.function([x, y], x * y) import unittest try: f(rand_cuda_ndarray((10, 3)), rand_cuda_ndarray((10, 1))) except ValueError: pass else: raise Exception("Theano should have raised an error") |
if scalar_op.output_types_preference in (T.scal.upgrade_to_float, T.scal.upcast_out): | if getattr(scalar_op,'output_types_preference',None) in (T.scal.upgrade_to_float, T.scal.upcast_out): | def local_upcast_elemwise_constant_inputs(node): """This explicitly upcasts constant inputs to elemwise Ops, when those Ops do implicit upcasting anyway. Rationale: it helps merge things like (1-x) and (1.0 - x). """ if isinstance(node.op, T.Elemwise): scalar_op = node.op.scalar_op #print "aa", scalar_op.output_types_... |
f = theano.function([], cpu_sample) | f = theano.function([], cpu_sample, mode=mode) | def test_consistency_GPU_parallel(): '''Verify that the random numbers generated by GPU_mrg_uniform, in parallel, are the same as the reference (Java) implementation by L'Ecuyer et al. ''' if not cuda_available: raise SkipTest('Optional package cuda not available') if config.mode == 'FAST_COMPILE': mode = 'FAST_RUN' el... |
ff = theano.function([], nn, mode=mode) | ff = theano.function([], nn) | def basictest(f, steps, target_avg, target_std, prefix=""): dt = 0.0 avg_std = 0.0 for i in xrange(steps): t0 = time.time() ival = f() dt += time.time() - t0 ival = numpy.asarray(ival) if i == 0: mean = numpy.array(ival, copy=True) avg_std = numpy.std(ival) else: alpha = 1.0 / (1+i) mean = alpha * ival + (1-alpha)*mean... |
setup_z_Nz_Sz = """ if ((NULL == %(_z)s) || (%(_z)s->dimensions[0] != %(_x)s->dimensions[0]) || (%(_z)s->dimensions[1] != %(_y)s->dimensions[1])) { if (NULL != %(_z)s) Py_XDECREF(%(_z)s); npy_intp dims[2]; dims[0] = %(_x)s->dimensions[0]; dims[1] = %(_y)s->dimensions[1]; %(_z)s = (PyArrayObject*)PyArray_SimpleNew(2, di... | setup_z_Nz_Sz = Dot22.setup_z_Nz_Sz | def __str__(self): return "_dot22scalar" |
def c_code(self, node, name, (_x, _y, _a), (_z, ), sub): | def c_code(self, node, name, (_x, _y, _a), (_zout, ), sub): | def c_code(self, node, name, (_x, _y, _a), (_z, ), sub): #DEBUG if len(self.c_libraries())<=0: return super(Dot22Scalar, self).c_code(node, name, (_x, _y), (_z, ), sub) full_code = self.build_gemm_call() % dict(locals(), **sub) return full_code |
return super(Dot22Scalar, self).c_code(node, name, (_x, _y), (_z, ), sub) | return super(Dot22Scalar, self).c_code(node, name, (_x, _y), (_zout, ), sub) | def c_code(self, node, name, (_x, _y, _a), (_z, ), sub): #DEBUG if len(self.c_libraries())<=0: return super(Dot22Scalar, self).c_code(node, name, (_x, _y), (_z, ), sub) full_code = self.build_gemm_call() % dict(locals(), **sub) return full_code |
return (1,) + self.build_gemm_version() | return (2,) + self.build_gemm_version() | def c_code_cache_version(self): return (1,) + self.build_gemm_version() |
if any([isinstance(x.op,Mod) for x in env.toposort()]): s = s.replace('% ','%% ') | def __init__(self, inputs, outputs): self.inputs=copy(inputs) self.outputs=copy(outputs) | |
if not _may_share_memory(storage_map[node.outputs[oo]][0],storage_map[node.inputs[ii[0]]][0]): | out_var = storage_map[node.outputs[oo]][0] in_var = storage_map[node.inputs[ii[0]]][0] if not _may_share_memory(out_var, in_var): | def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes, clobber_dr_vals=True, perform=None, warn_input_not_reused=True): """Raise BadDestroyMap if necessary, update dr_vals""" destroyed_idx_list = [] destroy_map = getattr(node.op, 'destroy_map', {}) for o_pos, i_pos_list in destroy_map.iteritems(): destroye... |
if storage_map[node.outputs[oo]][0].ndim>0 and storage_map[node.outputs[oo]][0].size>0: import pdb;pdb.set_trace() _may_share_memory(storage_map[node.outputs[oo]][0],storage_map[node.inputs[ii[0]]][0]) warning("input idx %d marked as viewed but new memory allocated by node '%s'"%(ii[0],str(node))) | if hasattr(out_var,'ndim') and (out_var.ndim>0 and out_var.size>0): continue warning("input idx %d marked as viewed but new memory allocated by node '%s'"%(ii[0],str(node))) | def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes, clobber_dr_vals=True, perform=None, warn_input_not_reused=True): """Raise BadDestroyMap if necessary, update dr_vals""" destroyed_idx_list = [] destroy_map = getattr(node.op, 'destroy_map', {}) for o_pos, i_pos_list in destroy_map.iteritems(): destroye... |
x = theano.tensor.dvector() | x = theano.tensor.vector() | def test_check_isfinite(self): x = theano.tensor.dvector() f = theano.function([x], (x+2) * 5, mode='DEBUG_MODE') |
try: f(numpy.log([3, -4, 5])) assert False except debugmode.InvalidValueError: pass try: f(numpy.asarray([0, 1.0, 0])/0) assert False except debugmode.InvalidValueError: pass try: f(numpy.asarray([1.0, 1.0, 1.0])/0) assert False except debugmode.InvalidValueError: pass | self.failUnlessRaises(ValueError, f, numpy.log([3, -4, 5])) self.failUnlessRaises(ValueError, f, numpy.asarray([0, 1.0, 0])/0) self.failUnlessRaises(ValueError, f, numpy.asarray([1.0, 1.0, 1.0])/0) self.failUnlessRaises(debugmode.InvalidValueError, g, [3,-4,5]) | def test_check_isfinite(self): x = theano.tensor.dvector() f = theano.function([x], (x+2) * 5, mode='DEBUG_MODE') |
exc_value.args = exc_value.args + (op, ) + ('Sequence id of Apply node='+str(op.env.toposort().index(op)),) | exc_value.args += (op, ) if op in op.env.toposort(): exc_value.args += ('Sequence id of Apply node='+str(op.env.toposort().index(op)),) | def raise_with_op(op, exc_info = None): """WRITEME""" if exc_info is None: exc_info = sys.exc_info() exc_type, exc_value, exc_trace = exc_info if exc_type == KeyboardInterrupt: # print a simple traceback from KeyboardInterrupt raise exc_type, exc_value, exc_trace try: trace = op.tag.trace except AttributeError: trace =... |
rng_state0 = numpy.random.RandomState(55) | rng_state0 = numpy.random.RandomState(utt.fetch_seed()) | def test_basic_usage(self): rf = RandomFunction(numpy.random.RandomState.uniform, tensor.dvector) assert not rf.inplace assert getattr(rf, 'destroy_map', {}) == {} |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r4, mutable=True)], [out2, out4, out2_4, out2_4_4], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r4, mutable=True)], [out2, out4, out2_4, out2_4_4], | def test_args(self): """Test that arguments to RandomFunction are honored""" rf2 = RandomFunction(numpy.random.RandomState.uniform, tensor.dvector) rf4 = RandomFunction(numpy.random.RandomState.uniform, tensor.dvector, inplace=True) rng_R = random_state_type() |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r2, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r2, mutable=True)], | def test_inplace_optimization(self): """Test that FAST_RUN includes the random_make_inplace optimization""" #inplace = False rf2 = RandomFunction(numpy.random.RandomState.uniform, tensor.dvector) rng_R = random_state_type() |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_out2_4_4, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_out2_4_4, mutable=True)], | def test_random_function_ndim(self): """Test that random_function helper function accepts argument ndim""" rng_R = random_state_type() |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=p_uni11, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=p_uni11, mutable=True)], | def randomfunction(random_state, size=(), low=0.0, high=0.0, ndim=None): ndim, size = raw_random._infer_ndim(ndim, size) op = RandomFunction('uniform', tensor.TensorType(dtype = 'float64', broadcastable = (False,)*(ndim+ndim_added)), ndim_added=ndim_added) return op(random_state, size, low, high) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=p_uni12, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=p_uni12, mutable=True)], | def randomfunction(random_state, size=(), low=0.0, high=0.0, ndim=None): ndim, size = raw_random._infer_ndim(ndim, size) op = RandomFunction('uniform', tensor.TensorType(dtype = 'float64', broadcastable = (False,)*(ndim+ndim_added)), ndim_added=ndim_added) return op(random_state, size, low, high) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=p_unim11, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=p_unim11, mutable=True)], | def randomfunction(random_state, size=(), low=0.0, high=0.0, ndim=None): ndim, size = raw_random._infer_ndim(ndim, size) op = RandomFunction('uniform', tensor.TensorType(dtype = 'float64', broadcastable = (False,)*(ndim+ndim_added)), ndim_added=ndim_added) return op(random_state, size, low, high) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=p_unim12, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=p_unim12, mutable=True)], | def randomfunction(random_state, size=(), low=0.0, high=0.0, ndim=None): ndim, size = raw_random._infer_ndim(ndim, size) op = RandomFunction('uniform', tensor.TensorType(dtype = 'float64', broadcastable = (False,)*(ndim+ndim_added)), ndim_added=ndim_added) return op(random_state, size, low, high) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=p_uni02, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=p_uni02, mutable=True)], | def randomfunction(random_state, size=(), low=0.0, high=0.0, ndim=None): ndim, size = raw_random._infer_ndim(ndim, size) op = RandomFunction('uniform', tensor.TensorType(dtype = 'float64', broadcastable = (False,)*(ndim+ndim_added)), ndim_added=ndim_added) return op(random_state, size, low, high) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_uniform(self): """Test that raw_random.uniform generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters post_r, out = uniform(rng_R, (4,), -2.0, 2.0) |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_uniform(self): """Test that raw_random.uniform generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters post_r, out = uniform(rng_R, (4,), -2.0, 2.0) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_binomial(self): """Test that raw_random.binomial generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters, and larger dimensions because of # the integer nature of the result post_r, bin = binomial(r... |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_binomial(self): """Test that raw_random.binomial generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters, and larger dimensions because of # the integer nature of the result post_r, bin = binomial(r... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_normal(self): """Test that raw_random.normal generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters post_r, out = normal(rng_R, (2,3), 4.0, 2.0) |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_normal(self): """Test that raw_random.normal generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters post_r, out = normal(rng_R, (2,3), 4.0, 2.0) |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_random_integers(self): """Test that raw_random.random_integers generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters, and larger dimensions because of # the integer nature of the result post_r, ou... |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_random_integers(self): """Test that raw_random.random_integers generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() # Use non-default parameters, and larger dimensions because of # the integer nature of the result post_r, ou... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_permutation_helper(self): """Test that raw_random.permutation_helper generates the same results as numpy, and that the 'ndim_added' keyword behaves correctly.""" # permutation_helper needs "ndim_added=1", because its output # is one dimension more than its "shape" argument (and there's # no way to determine th... |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_permutation_helper(self): """Test that raw_random.permutation_helper generates the same results as numpy, and that the 'ndim_added' keyword behaves correctly.""" # permutation_helper needs "ndim_added=1", because its output # is one dimension more than its "shape" argument (and there's # no way to determine th... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r0, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r0, mutable=True)], | def test_permutation_helper(self): """Test that raw_random.permutation_helper generates the same results as numpy, and that the 'ndim_added' keyword behaves correctly.""" # permutation_helper needs "ndim_added=1", because its output # is one dimension more than its "shape" argument (and there's # no way to determine th... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r2, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r2, mutable=True)], | def test_permutation_helper(self): """Test that raw_random.permutation_helper generates the same results as numpy, and that the 'ndim_added' keyword behaves correctly.""" # permutation_helper needs "ndim_added=1", because its output # is one dimension more than its "shape" argument (and there's # no way to determine th... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_permutation(self): """Test that raw_random.permutation generates the same results as numpy.""" rng_R = random_state_type() post_r, out = permutation(rng_R, size=(9,), n=6) print 'OUT NDIM', out.ndim f = compile.function( [compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], [out... |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_permutation(self): """Test that raw_random.permutation generates the same results as numpy.""" rng_R = random_state_type() post_r, out = permutation(rng_R, size=(9,), n=6) print 'OUT NDIM', out.ndim f = compile.function( [compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], [out... |
[compile.In(rng_R, value=numpy.random.RandomState(55), update=post_r, mutable=True)], | [compile.In(rng_R, value=numpy.random.RandomState(utt.fetch_seed()), update=post_r, mutable=True)], | def test_multinomial(self): """Test that raw_random.multinomial generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() post_r, out = multinomial(rng_R, (7,3), 6, [0.2]*5) |
numpy_rng = numpy.random.RandomState(55) | numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_multinomial(self): """Test that raw_random.multinomial generates the same results as numpy.""" # Check over two calls to see if the random state is correctly updated. rng_R = random_state_type() post_r, out = multinomial(rng_R, (7,3), 6, [0.2]*5) |
rng_state0 = numpy.random.RandomState(55) | rng_state0 = numpy.random.RandomState(utt.fetch_seed()) | def test_symbolic_shape(self): rng_R = random_state_type() |
rng_state0 = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng_state0 = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_default_shape(self): rng_R = random_state_type() post_r, out = uniform(rng_R) f = compile.function([rng_R], [post_r, out], accept_inplace=True) |
rng_state0 = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng_state0 = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_vector_arguments(self): rng_R = random_state_type() low = tensor.vector() post_r, out = uniform(rng_R, low=low, high=1) assert out.ndim == 1 f = compile.function([rng_R, low], [post_r, out], accept_inplace=True) |
rng_state0 = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng_state0 = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_broadcast_arguments(self): rng_R = random_state_type() low = tensor.vector() high = tensor.col() post_r, out = uniform(rng_R, low=low, high=high) assert out.ndim == 2 f = compile.function([rng_R, low, high], [post_r, out], accept_inplace=True) |
rng = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_uniform_vector(self): rng_R = random_state_type() low = tensor.vector() high = tensor.vector() post_r, out = uniform(rng_R, low=low, high=high) assert out.ndim == 1 f = compile.function([rng_R, low, high], [post_r, out], accept_inplace=True) |
rng = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_binomial_vector(self): rng_R = random_state_type() n = tensor.lvector() prob = tensor.vector() post_r, out = binomial(rng_R, n=n, prob=prob) assert out.ndim == 1 f = compile.function([rng_R, n, prob], [post_r, out], accept_inplace=True) |
rng = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_normal_vector(self): rng_R = random_state_type() avg = tensor.vector() std = tensor.vector() post_r, out = normal(rng_R, avg=avg, std=std) assert out.ndim == 1 f = compile.function([rng_R, avg, std], [post_r, out], accept_inplace=True) |
rng = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_random_integers_vector(self): rng_R = random_state_type() low = tensor.lvector() high = tensor.lvector() post_r, out = random_integers(rng_R, low=low, high=high) assert out.ndim == 1 f = compile.function([rng_R, low, high], [post_r, out], accept_inplace=True) |
rng = numpy.random.RandomState(55) numpy_rng = numpy.random.RandomState(55) | rng = numpy.random.RandomState(utt.fetch_seed()) numpy_rng = numpy.random.RandomState(utt.fetch_seed()) | def test_multinomial_vector(self): rng_R = random_state_type() n = tensor.lvector() pvals = tensor.matrix() post_r, out = multinomial(rng_R, n=n, pvals=pvals) assert out.ndim == 2 f = compile.function([rng_R, n, pvals], [post_r, out], accept_inplace=True) |
a = theano.shared(_a) b = theano.shared(_b) | a = tcn.shared_constructor(_a) b = tcn.shared_constructor(_b) | def test_gpujoin_twomatrices_joincolumns(): _a = numpy.asarray([[1,2],[3,4]],dtype='float32') _b = numpy.asarray([[5,6,7],[8,9,10]],dtype='float32') a = theano.shared(_a) b = theano.shared(_b) c = gpu_join(1,a,b) f = theano.function([], c) assert numpy.all(f() == numpy.concatenate([_a,_b], axis=1)) |
a = theano.shared(_a) b = theano.shared(_b) | a = tcn.shared_constructor(_a) b = tcn.shared_constructor(_b) | def test_gpujoin_twomatrices_badshapes(): _a = numpy.asarray([[1,2],[3,4]],dtype='float32') _b = numpy.asarray([[5,6,7],[8,9,10]],dtype='float32') a = theano.shared(_a) b = theano.shared(_b) # try to join on dimension 0 where they don't agree (2!=3) c = gpu_join(0,a,b) f = theano.function([], c) try: f() assert Fals... |
a = theano.shared(_a) b = theano.shared(_b) | a = tcn.shared_constructor(_a) b = tcn.shared_constructor(_b) | def test_gpujoin_preserves_broadcasting(): _a = numpy.asarray([[1,2],[3,4]],dtype='float32') _b = numpy.asarray([[5,6,7],[8,9,10]],dtype='float32') a = theano.shared(_a) b = theano.shared(_b) # [0,0] : the two original dims were non-broadcastable # [1,x,0]: new order and broadcastability gpu_dimshuffle = GpuDimShuffle... |
f = theano.function([], c) | f = theano.function([], c, mode=mode_with_gpu) | def test_gpujoin_preserves_broadcasting(): _a = numpy.asarray([[1,2],[3,4]],dtype='float32') _b = numpy.asarray([[5,6,7],[8,9,10]],dtype='float32') a = theano.shared(_a) b = theano.shared(_b) # [0,0] : the two original dims were non-broadcastable # [1,x,0]: new order and broadcastability gpu_dimshuffle = GpuDimShuffle... |
if host_input.owner and host_input.owner.op == tensor.blas.gemm: | if host_input.owner and host_input.owner.op == tensor.blas.gemm_inplace: | def local_gpu_gemm(node): """ gpu_from_host(gemm) -> gpu_gemm(gpu_from_host) gemm(host_from_gpu) -> host_from_gpu(gpu_gemm) """ if node.op == gpu_from_host: host_input = node.inputs[0] if host_input.owner and host_input.owner.op == tensor.blas.gemm: z, a, x, y, b = host_input.owner.inputs return [gpu_gemm(gpu_from_hos... |
if node.op == tensor.blas.gemm: | if node.op == tensor.blas.gemm_inplace: | def local_gpu_gemm(node): """ gpu_from_host(gemm) -> gpu_gemm(gpu_from_host) gemm(host_from_gpu) -> host_from_gpu(gpu_gemm) """ if node.op == gpu_from_host: host_input = node.inputs[0] if host_input.owner and host_input.owner.op == tensor.blas.gemm: z, a, x, y, b = host_input.owner.inputs return [gpu_gemm(gpu_from_hos... |
type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s | def c_extract(self, name, sub): """Override `CLinkerOp.c_extract` """ # TODO: make the error message print out the dtype of the # input received. return """ %(name)s = NULL; type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s if (py_%(name)s == Py_None) { // We can either fail h... | |
else if (!PyArray_Check(py_%(name)s)) { | if (!PyArray_Check(py_%(name)s)) { | def c_extract(self, name, sub): """Override `CLinkerOp.c_extract` """ # TODO: make the error message print out the dtype of the # input received. return """ %(name)s = NULL; type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s if (py_%(name)s == Py_None) { // We can either fail h... |
else if (type_num_%(name)s != %(type_num)s) { | type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s if (type_num_%(name)s != %(type_num)s) { | def c_extract(self, name, sub): """Override `CLinkerOp.c_extract` """ # TODO: make the error message print out the dtype of the # input received. return """ %(name)s = NULL; type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s if (py_%(name)s == Py_None) { // We can either fail h... |
else { %(name)s = (PyArrayObject*)(py_%(name)s); Py_XINCREF(%(name)s); } | %(name)s = (PyArrayObject*)(py_%(name)s); Py_XINCREF(%(name)s); | def c_extract(self, name, sub): """Override `CLinkerOp.c_extract` """ # TODO: make the error message print out the dtype of the # input received. return """ %(name)s = NULL; type_num_%(name)s = ((PyArrayObject*)py_%(name)s)->descr->type_num; //we expect %(type_num)s if (py_%(name)s == Py_None) { // We can either fail h... |
return (1,) + scalar_version | return (2,) + scalar_version | def c_code_cache_version(self): scalar_version = scal.Scalar(self.dtype).c_code_cache_version() if scalar_version: return (1,) + scalar_version else: return () |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.