提交 d382ccc7 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

added version numbers to the Conv3D ops

上级 6f2a1b03
...@@ -4414,6 +4414,7 @@ class numeric_grad: ...@@ -4414,6 +4414,7 @@ class numeric_grad:
x[i] += eps x[i] += eps
f_eps = f(*apt) f_eps = f(*apt)
gx[i] = numpy.asarray((f_eps - f_x)/eps) gx[i] = numpy.asarray((f_eps - f_x)/eps)
if packed_pt: if packed_pt:
...@@ -4594,6 +4595,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None, abs_tol=None, rel_tol=No ...@@ -4594,6 +4595,7 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None, abs_tol=None, rel_tol=No
for test_num in xrange(n_tests): for test_num in xrange(n_tests):
num_grad = numeric_grad(cost_fn, [p.copy() for p in pt], eps) num_grad = numeric_grad(cost_fn, [p.copy() for p in pt], eps)
analytic_grad = grad_fn(*[p.copy() for p in pt]) analytic_grad = grad_fn(*[p.copy() for p in pt])
if not isinstance(analytic_grad, (list, tuple)): if not isinstance(analytic_grad, (list, tuple)):
...@@ -4621,6 +4623,7 @@ class GradientError(Exception): ...@@ -4621,6 +4623,7 @@ class GradientError(Exception):
self.abs_tol = abs_tol self.abs_tol = abs_tol
self.rel_tol = rel_tol self.rel_tol = rel_tol
def __str__(self): def __str__(self):
return """GradientError: numeric gradient and analytic gradient exceed tolerance: return """GradientError: numeric gradient and analytic gradient exceed tolerance:
At position %i of argument %i, At position %i of argument %i,
......
...@@ -49,6 +49,10 @@ class Conv3D(theano.Op): ...@@ -49,6 +49,10 @@ class Conv3D(theano.Op):
def __str__(self): def __str__(self):
return "Conv3D" return "Conv3D"
def c_code_cache_version(self):
return (1,)
def make_node(self, V, W, b, d): def make_node(self, V, W, b, d):
""" """
:param V: Visible unit, input(batch,row,column,time,in channel) :param V: Visible unit, input(batch,row,column,time,in channel)
......
...@@ -3,6 +3,10 @@ from theano.tensor import basic as T ...@@ -3,6 +3,10 @@ from theano.tensor import basic as T
from theano.misc import strutil from theano.misc import strutil
import numpy as N import numpy as N
#TODO: speed up by reordering loops. Should pass through the videos once, incrementing all weight gradients, rather
# than visiting each weight gradient element once and passing through whole video
class ConvGrad3D(theano.Op): class ConvGrad3D(theano.Op):
""" Gradient of Conv3D with respect to W """ """ Gradient of Conv3D with respect to W """
def __eq__(self,other): def __eq__(self,other):
...@@ -11,6 +15,9 @@ class ConvGrad3D(theano.Op): ...@@ -11,6 +15,9 @@ class ConvGrad3D(theano.Op):
def __hash__(self): def __hash__(self):
return hash(type(self)) return hash(type(self))
def c_code_cache_version(self):
return (1,)
def make_node(self, V, d, WShape, dCdH): def make_node(self, V, d, WShape, dCdH):
V_ = T.as_tensor_variable(V) V_ = T.as_tensor_variable(V)
d_ = T.as_tensor_variable(d) d_ = T.as_tensor_variable(d)
......
...@@ -11,6 +11,9 @@ class ConvTransp3D(theano.Op): ...@@ -11,6 +11,9 @@ class ConvTransp3D(theano.Op):
def __hash__(self): def __hash__(self):
return hash(type(self)) return hash(type(self))
def c_code_cache_version(self):
return (1,)
def make_node(self, W, b, d, H, RShape = None): def make_node(self, W, b, d, H, RShape = None):
""" """
:param W: Weights, filter :param W: Weights, filter
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论