提交 c79a35b3 authored 作者: Frederic Bastien's avatar Frederic Bastien

re-enable neibs2images while adding it missing parameter. Warn when that we…

re-enable neibs2images while adding it missing parameter. Warn when that we don't implement the extra parameter if they are not at their default value for now.
上级 e597582a
...@@ -211,21 +211,36 @@ class Images2Neibs(Op): ...@@ -211,21 +211,36 @@ class Images2Neibs(Op):
def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'): def images2neibs(ten4, neib_shape, neib_step=None, mode='valid'):
return Images2Neibs(mode)(ten4, neib_shape, neib_step) return Images2Neibs(mode)(ten4, neib_shape, neib_step)
def neibs2images(neibs, neib_shape, original_shape): def neibs2images(neibs, neib_shape, original_shape, neib_step=None, mode='valid'):
""" """
Inverse of images2neib. Inverse of images2neib. Don't implement neib_step and mode.
neibs : matrix like the one obtained by images2neib
neib_shape : neib_shape that was used in images2neib
original_shape : original shape of the 4d tensor given to images2neib
:type neibs: Theano variable
:param neibs: matrix like the one obtained by images2neib
:type neib_shape: Theano variable
:param neib_shape: neib_shape that was used in images2neib
:type original_shape: Theano variable
:param original_shape: original shape of the 4d tensor given to images2neib.
:type neib_step: Theano variable or None
:param neib_step: neib_step that was used in images2neib Implement only None.
None is non overlapping patches and not-adjacent patches.
:type mode: str
:param mode: The mode that was used in images2neib. Implement only valid.
Return a 4d tensor of shape `original_shape`. Return a 4d tensor of shape `original_shape`.
""" """
# TODO: handle the case where patches either overlap # TODO: handle the case where patches either overlap
# TODO: handle the case where patches are not directly adjacent # TODO: handle the case where patches are not directly adjacent
# TODO: at least separate these cases so that the following code does not incorrectly # TODO: at least separate these cases so that the following code does not incorrectly
# handle them by accident. # handle them by accident.
raise NotImplementedError('check for overlapping patches or non-adjacent patches.') if neib_step != None:
raise NotImplementedError('neibs2images do not implement overlapping patches or non-adjacent patches.')
if mode != 'valid':
raise NotImplementedError('neibs2images do not implement the mode %s. It currently only implement `valid`.'%mode)
neibs = T.as_tensor_variable(neibs) neibs = T.as_tensor_variable(neibs)
neib_shape = T.as_tensor_variable(neib_shape) neib_shape = T.as_tensor_variable(neib_shape)
original_shape = T.as_tensor_variable(original_shape) original_shape = T.as_tensor_variable(original_shape)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论