提交 3167f410 authored 作者: Frederic's avatar Frederic

Add missing file from the refactoring.

上级 a37ccad2
...@@ -53,10 +53,6 @@ int_dtypes = map(str, scal.int_types) ...@@ -53,10 +53,6 @@ int_dtypes = map(str, scal.int_types)
uint_dtypes = map(str, scal.uint_types) uint_dtypes = map(str, scal.uint_types)
# Do a lazy import of the sparse module
sparse_module_ref = None
class ShapeError(Exception): class ShapeError(Exception):
"""Raised when the shape cannot be computed.""" """Raised when the shape cannot be computed."""
pass pass
......
差异被折叠。
差异被折叠。
#
# Slice type and Op. None Type and NoneConst.
#
from theano.gof import Apply, Constant, Op, Type
from theano.gradient import DisconnectedType
class MakeSlice(Op):
def make_node(self, slc):
return Apply(self,
map(as_int_none_variable,
[slc.start, slc.stop, slc.step]),
[slicetype()])
def perform(self, node, inp, out_):
out, = out_
out[0] = slice(*inp)
def __str__(self):
return self.__class__.__name__
def __eq__(self, other):
return type(self) == type(other)
def __hash__(self):
return hash(type(self))
def grad(self, inputs, grads):
return [DisconnectedType()() for i in inputs]
make_slice = MakeSlice()
class SliceType(Type):
def filter(self, x, strict=False, allow_downcast=None):
if isinstance(x, slice):
return x
else:
raise TypeError('Expected a slice!')
def __str__(self):
return "slice"
slicetype = SliceType()
class NoneTypeT(Type):
def filter(self, x, strict=False, allow_downcast=None):
if x is None:
return x
else:
raise TypeError('Expected None!')
def __str__(self):
return "None"
NoneConst = Constant(NoneTypeT(), None, name='None')
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论