提交 3baaed7b authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Pep8

上级 c1cdabc8
import numpy import numpy
import theano
from theano import gof from theano import gof
from theano.gof import Apply, Constant, Generic, Op, Type, Variable from theano.gof import Constant, Generic, Op
from basic import tensor from basic import tensor
########################## ##########################
# Disk Access # Disk Access
########################## ##########################
class LoadFromDisk(Op): class LoadFromDisk(Op):
""" """
An operation to load an array from disk An operation to load an array from disk
...@@ -40,15 +40,17 @@ class LoadFromDisk(Op): ...@@ -40,15 +40,17 @@ class LoadFromDisk(Op):
def perform(self, node, inp, out): def perform(self, node, inp, out):
path = inp[0] path = inp[0]
if (path.split('.')[-1] == 'npz'): if (path.split('.')[-1] == 'npz'):
raise ValueError("Expected a .npy file, got %s instead"%path) raise ValueError("Expected a .npy file, got %s instead" % path)
result = numpy.load(path, mmap_mode=self.mmap_mode) result = numpy.load(path, mmap_mode=self.mmap_mode)
if result.dtype != self.dtype: if result.dtype != self.dtype:
raise TypeError("Expected an array of type %s, got %s instead"% raise TypeError("Expected an array of type %s, got %s instead" %
(self.dtype, result.dtype)) (self.dtype, result.dtype))
print 'result:', result, type(result)
out[0][0] = result out[0][0] = result
def __str__(self): def __str__(self):
return "Load{dtype:%s, broadcastable:%s, mmep:%s}"%self._info return "Load{dtype:%s, broadcastable:%s, mmep:%s}" % self._info
def load(path, dtype, broadcastable, mmap_mode=None): def load(path, dtype, broadcastable, mmap_mode=None):
""" """
...@@ -76,4 +78,3 @@ def load(path, dtype, broadcastable, mmap_mode=None): ...@@ -76,4 +78,3 @@ def load(path, dtype, broadcastable, mmap_mode=None):
""" """
return LoadFromDisk(dtype, broadcastable, mmap_mode)(path) return LoadFromDisk(dtype, broadcastable, mmap_mode)(path)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论