本文整理汇总了Python中theano.gradient.grad_not_implemented函数的典型用法代码示例。如果您正苦于以下问题:Python grad_not_implemented函数的具体用法?Python grad_not_implemented怎么用?Python grad_not_implemented使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grad_not_implemented函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: grad
def grad(self, inp, grads):
softmaxes, y_idxes, y_lengths, y_startidxes = inp
g_costs, = grads
return [masked_loss_dx(softmaxes, y_idxes, y_lengths, y_startidxes, g_costs),
grad_not_implemented(self, 1, y_idxes),
grad_not_implemented(self, 1, y_lengths),
grad_not_implemented(self, 1, y_startidxes)]
开发者ID:Beronx86,项目名称:theano_lstm,代码行数:7,代码来源:masked_loss.py
示例2: grad
def grad(self, inputs, gradients):
x, new_length, nonconstants = inputs
d_out = gradients[0]
swap = range(self.ndim)
swap.remove(self.axis)
swap.insert(0, self.axis)
return [
d_out.dimshuffle(swap)[nonconstants].dimshuffle(swap),
grad_not_implemented(self, 1, new_length),
grad_not_implemented(self, 2, nonconstants),
]
开发者ID:sonu5623,项目名称:pylearn2,代码行数:11,代码来源:insert_along_axis.py
示例3: grad
def grad(self, inp, grads):
kerns, top, output, desc, alpha, beta = inp
img, = grads
img = gpu_contiguous(img)
d_kerns = GpuDnnConvGradW()(img, top, empty_like(kerns), desc)
d_top = GpuDnnConv()(img, kerns, empty_like(top), desc)
d_alpha = grad_not_implemented(self, 4, alpha)
d_beta = grad_not_implemented(self, 5, beta)
return (d_kerns * alpha, d_top * alpha, img * beta, DisconnectedType()(), d_alpha, d_beta)
开发者ID:hhoareau,项目名称:Theano,代码行数:12,代码来源:dnn.py
示例4: grad
def grad(self, inp, grads):
kerns, top, output, desc, alpha, beta = inp
img, = grads
img = gpu_contiguous(img)
d_kerns = GpuDnn3dConvGradW()(img, top, gpu_alloc_empty(*kerns.shape), desc)
d_top = GpuDnn3dConv()(img, kerns, gpu_alloc_empty(*top.shape), desc)
d_alpha = grad_not_implemented(self, 4, alpha)
d_beta = grad_not_implemented(self, 5, beta)
return (d_kerns * alpha, d_top * alpha, img * beta,
DisconnectedType()(), d_alpha, d_beta)
开发者ID:robintibor,项目名称:pylearn3dconv,代码行数:12,代码来源:conv.py
示例5: grad
def grad(self, inp, grads):
x, neib_shape, neib_step = inp
gz, = grads
if self.mode in ['valid', 'ignore_borders']:
if (neib_shape is neib_step or
neib_shape == neib_step or
# Theano Constant == do not compare the data
# the equals function do that.
(hasattr(neib_shape, "equals") and
neib_shape.equals(neib_step))):
return [neibs2images(gz, neib_shape, x.shape, mode=self.mode),
grad_undefined(self, 1, neib_shape),
grad_undefined(self, 2, neib_step)]
if self.mode in ['valid']:
# Iterate over neighborhood positions, summing contributions.
def pos2map(pidx, pgz, prior_result, neib_shape, neib_step):
'''
Helper function that adds gradient contribution from a single
neighborhood position i,j.
pidx = Index of position within neighborhood.
pgz = Gradient of shape (batch_size*num_channels*neibs)
prior_result = Shape (batch_size, num_channnels, rows, cols)
neib_shape = Number of rows, cols in a neighborhood.
neib_step = Step sizes from image2neibs.
'''
nrows, ncols = neib_shape
rstep, cstep = neib_step
batch_size, num_channels, rows, cols = prior_result.shape
i = pidx // ncols
j = pidx - (i * ncols)
# This position does not touch some img pixels in valid mode.
result_indices = prior_result[:, :,
i:(rows - nrows + i + 1):rstep,
j:(cols - ncols + j + 1):cstep]
newshape = (batch_size, num_channels) + \
((rows - nrows) // rstep + 1,) + \
((cols - ncols) // cstep + 1,)
return T.inc_subtensor(result_indices, pgz.reshape(newshape))
indices = T.arange(neib_shape[0] * neib_shape[1])
pgzs = gz.dimshuffle((1, 0))
result, _ = theano.scan(fn=pos2map,
sequences=[indices, pgzs],
outputs_info=T.zeros(x.shape),
non_sequences=[neib_shape, neib_step])
grad_input = result[-1]
return [grad_input,
grad_undefined(self, 1, neib_shape),
grad_undefined(self, 2, neib_step)]
return [grad_not_implemented(self, 0, x),
grad_undefined(self, 1, neib_shape),
grad_undefined(self, 2, neib_step)]
开发者ID:Faruk-Ahmed,项目名称:Theano,代码行数:54,代码来源:neighbours.py
示例6: grad
def grad(self, inp, grads):
x, neib_shape, neib_step = inp
gz, = grads
if self.mode in ['valid', 'ignore_borders']:
if (neib_shape is neib_step or
neib_shape == neib_step or
# Theano Constant == do not compare the data
# the equals function do that.
(hasattr(neib_shape, "equals") and
neib_shape.equals(neib_step))):
return [neibs2images(gz, neib_shape, x.shape, mode=self.mode),
grad_undefined(self, 1, neib_shape),
grad_undefined(self, 2, neib_step)]
return [grad_not_implemented(self, 0, x),
grad_undefined(self, 1, neib_shape),
grad_undefined(self, 2, neib_step)]
开发者ID:c0g,项目名称:Theano,代码行数:17,代码来源:neighbours.py
示例7: grad
def grad(self, inputs, gout):
(input_x,) = inputs
return [grad_not_implemented(self, 0, input_x)]
开发者ID:juancamilog,项目名称:Theano,代码行数:3,代码来源:subtensor.py
示例8: grad
def grad(self, inputs, grads):
v, x = inputs
gz, = grads
return [grad_not_implemented(self, 0, v),
gz * (iv(v - 1, x) + iv(v + 1, x)) / 2.]
开发者ID:Thrandis,项目名称:Theano,代码行数:5,代码来源:basic_scipy.py
示例9: grad
def grad(self, inputs, ograds):
return [grad_not_implemented(self, i, inputs[i]) for i in xrange(len(inputs))]
开发者ID:mila-udem,项目名称:platoon,代码行数:2,代码来源:ops.py
示例10: grad
def grad(self, inp, grads):
coding, one_of_n = inp
g_y, = grads
crossentropy_categorical_1hot_grad = rocGrad()
return [crossentropy_categorical_1hot_grad(g_y, coding, one_of_n),
grad_not_implemented(self, 1, one_of_n)]
开发者ID:PPPW,项目名称:Kaggle-Springleaf-Marketing-Response,代码行数:6,代码来源:springleaf.py
注:本文中的theano.gradient.grad_not_implemented函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论