提交 31c1c6a2 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

PEP8 compatibility

上级 840176c8
......@@ -12,7 +12,8 @@ import blas
import blas_scipy
import xlogx
import raw_random, randomstreams
import raw_random
import randomstreams
import shared_randomstreams
from randomstreams import \
RandomStreams
......@@ -21,9 +22,9 @@ random = RandomStreams(seed=0xBAD5EED)
"""Imitate the numpy.random symbol with a tensor.random one"""
from elemwise import \
DimShuffle, Elemwise, CAReduce
DimShuffle, Elemwise, CAReduce, Any, All
import sharedvar # adds shared-variable constructors
import sharedvar # adds shared-variable constructors
# We import as `_shared` instead of `shared` to avoid confusion between
# `theano.shared` and `tensor._shared`.
......@@ -47,8 +48,14 @@ def shared(*args, **kw):
return _shared(*args, **kw)
import nnet # used for softmax, sigmoid, etc.
import nnet # used for softmax, sigmoid, etc.
from tensor_grad import Rop, Lop, grad, numeric_grad, verify_grad
def any(x, axis=None):
return Any(axis)(x)
def all(x, axis=None):
return All(axis)(x)
from tensor_grad import Rop, Lop, grad, numeric_grad, verify_grad
......@@ -1258,6 +1258,42 @@ for(int i=0;i<%(iname)s->nd;i++){
return ()
class All(CAReduce):
"""
Equivalent to numpy any
TODO: elaborate
"""
def __init__(self, axis=None):
CAReduce.__init__(self, scalar.and_, axis)
def _output_dtype(self, idtype):
return "int8"
def __str__(self):
if self.axis is None:
return "All"
else:
return "All{%s}" % ", ".join(map(str, self.axis))
class Any(CAReduce):
"""
Equivalent to numpy any
TODO: elaborate
"""
def __init__(self, axis=None):
CAReduce.__init__(self, scalar.or_, axis)
def _output_dtype(self, idtype):
return "int8"
def __str__(self):
if self.axis is None:
return "Any"
else:
return "Any{%s}" % ", ".join(map(str, self.axis))
class Sum(CAReduce):
"""
Sums all the values of a tensor along the specified axis(es).
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论