提交 8e24e782 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Update print warnings to use warnings.warn

This commit also removes redundant "WARNING" and "DEPRECATION" strings and, for the latter, sets the category (or raises) a `DeprecationWarning`.
上级 0d34af2e
import sys from warnings import warn
import numpy as np import numpy as np
import pytest import pytest
...@@ -197,7 +197,7 @@ class TestCGemv(OptimizationTestMixin): ...@@ -197,7 +197,7 @@ class TestCGemv(OptimizationTestMixin):
def test_force_gemv_init(self): def test_force_gemv_init(self):
if check_force_gemv_init(): if check_force_gemv_init():
sys.stderr.write( warn(
"WARNING: The current BLAS requires Theano to initialize" "WARNING: The current BLAS requires Theano to initialize"
+ " memory for some GEMV calls which will result in a minor" + " memory for some GEMV calls which will result in a minor"
+ " degradation in performance for such calls." + " degradation in performance for such calls."
......
...@@ -13,6 +13,7 @@ import sys ...@@ -13,6 +13,7 @@ import sys
from io import StringIO from io import StringIO
from itertools import chain from itertools import chain
from itertools import product as itertools_product from itertools import product as itertools_product
from warnings import warn
import numpy as np import numpy as np
...@@ -934,7 +935,7 @@ def _check_strides_match(a, b, warn_err, op): ...@@ -934,7 +935,7 @@ def _check_strides_match(a, b, warn_err, op):
if warn_err == 2: if warn_err == 2:
raise e raise e
else: else:
print("WARNING:", e, file=sys.stderr) warn(str(e))
def _lessbroken_deepcopy(a): def _lessbroken_deepcopy(a):
...@@ -2459,7 +2460,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions ...@@ -2459,7 +2460,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
l0 = fgraph0.equivalence_tracker.event_list l0 = fgraph0.equivalence_tracker.event_list
if li != l0: if li != l0:
infolog = StringIO() infolog = StringIO()
print("WARNING: Optimization process is unstable...", file=infolog) print("Optimization process is unstable...", file=infolog)
print( print(
" (HINT: Ops that the nodes point to must compare " "equal)", " (HINT: Ops that the nodes point to must compare " "equal)",
file=infolog, file=infolog,
......
...@@ -123,7 +123,7 @@ class AddDestroyHandler(gof.GlobalOptimizer): ...@@ -123,7 +123,7 @@ class AddDestroyHandler(gof.GlobalOptimizer):
break break
if not supervisor_added: if not supervisor_added:
warnings.warn( warnings.warn(
"WARNING: Supervisor is not added. Please build a FunctionGraph" "Supervisor is not added. Please build a FunctionGraph"
"via theano.compile.function.types.std_graph()" "via theano.compile.function.types.std_graph()"
"or add the Supervisor class manually.", "or add the Supervisor class manually.",
stacklevel=3, stacklevel=3,
......
...@@ -2014,7 +2014,7 @@ class GCC_compiler(Compiler): ...@@ -2014,7 +2014,7 @@ class GCC_compiler(Compiler):
and "icpc" not in theano.config.cxx and "icpc" not in theano.config.cxx
): ):
_logger.warning( _logger.warning(
"OPTIMIZATION WARNING: your Theano flag `cxx` seems not to be" "Your Theano flag `cxx` seems not to be"
" the g++ compiler. So we disable the compiler optimization" " the g++ compiler. So we disable the compiler optimization"
" specific to g++ that tell to compile for a specific CPU." " specific to g++ that tell to compile for a specific CPU."
" At worst, this could cause slow down.\n" " At worst, this could cause slow down.\n"
...@@ -2083,7 +2083,7 @@ class GCC_compiler(Compiler): ...@@ -2083,7 +2083,7 @@ class GCC_compiler(Compiler):
else: else:
reported_lines = native_lines reported_lines = native_lines
_logger.warning( _logger.warning(
"OPTIMIZATION WARNING: Theano was not able to find the" "Theano was not able to find the"
" g++ parameters that tune the compilation to your " " g++ parameters that tune the compilation to your "
" specific CPU. This can slow down the execution of Theano" " specific CPU. This can slow down the execution of Theano"
" functions. Please submit the following lines to" " functions. Please submit the following lines to"
...@@ -2095,7 +2095,7 @@ class GCC_compiler(Compiler): ...@@ -2095,7 +2095,7 @@ class GCC_compiler(Compiler):
_logger.info(f"g++ default lines: {default_lines}") _logger.info(f"g++ default lines: {default_lines}")
if len(default_lines) < 1: if len(default_lines) < 1:
_logger.warning( _logger.warning(
"OPTIMIZATION WARNING: Theano was not able to find the" "Theano was not able to find the"
" default g++ parameters. This is needed to tune" " default g++ parameters. This is needed to tune"
" the compilation to your specific" " the compilation to your specific"
" CPU. This can slow down the execution of Theano" " CPU. This can slow down the execution of Theano"
......
...@@ -3,6 +3,7 @@ import traceback ...@@ -3,6 +3,7 @@ import traceback
from copy import copy, deepcopy from copy import copy, deepcopy
from io import StringIO from io import StringIO
from sys import getsizeof from sys import getsizeof
from warnings import warn
import numpy as np import numpy as np
...@@ -334,7 +335,7 @@ def raise_with_op(fgraph, node, thunk=None, exc_info=None, storage_map=None): ...@@ -334,7 +335,7 @@ def raise_with_op(fgraph, node, thunk=None, exc_info=None, storage_map=None):
str(exc_value) + detailed_err_msg + "\n" + "\n".join(hints) str(exc_value) + detailed_err_msg + "\n" + "\n".join(hints)
) )
except TypeError: except TypeError:
print(f"WARNING: {exc_type} error does not allow us to add extra error message") warn(f"{exc_type} error does not allow us to add extra error message")
# Some exception need extra parameter in inputs. So forget the # Some exception need extra parameter in inputs. So forget the
# extra long error message in that case. # extra long error message in that case.
raise exc_value.with_traceback(exc_trace) raise exc_value.with_traceback(exc_trace)
......
...@@ -610,17 +610,15 @@ class ReplaceValidate(History, Validator): ...@@ -610,17 +610,15 @@ class ReplaceValidate(History, Validator):
if rm in fgraph.apply_nodes or rm in fgraph.variables: if rm in fgraph.apply_nodes or rm in fgraph.variables:
fgraph.revert(chk) fgraph.revert(chk)
if warn: if warn:
out = sys.stderr warn(
print( "An optimization wanted to replace a Variable"
"WARNING: An optimization wanted to replace a Variable"
" in the graph, but the replacement for it doesn't" " in the graph, but the replacement for it doesn't"
" remove it. We disabled the optimization." " remove it. We disabled the optimization."
" Your function runs correctly, but it would be" " Your function runs correctly, but it would be"
" appreciated if you submit this problem to the" " appreciated if you submit this problem to the"
" mailing list theano-users so that we can fix it.", " mailing list theano-users so that we can fix it."
file=out, f"{reason}: {replacements}",
) )
print(reason, replacements, file=out)
raise ReplacementDidNotRemoveError() raise ReplacementDidNotRemoveError()
def __getstate__(self): def __getstate__(self):
......
...@@ -3,6 +3,7 @@ import linecache ...@@ -3,6 +3,7 @@ import linecache
import sys import sys
import traceback import traceback
from io import StringIO from io import StringIO
from warnings import warn
from theano import config from theano import config
...@@ -397,7 +398,10 @@ def deprecated(filename, msg=""): ...@@ -397,7 +398,10 @@ def deprecated(filename, msg=""):
def g(*args, **kwargs): def g(*args, **kwargs):
if printme[0]: if printme[0]:
print(f"WARNING: {filename}.{f.__name__} deprecated. {msg}") warn(
f"{filename}.{f.__name__} deprecated. {msg}",
category=DeprecationWarning,
)
printme[0] = False printme[0] = False
return f(*args, **kwargs) return f(*args, **kwargs)
......
...@@ -24,11 +24,21 @@ try: ...@@ -24,11 +24,21 @@ try:
except ImportError: except ImportError:
pygpu = None pygpu = None
from . import ctc, dnn, extra_ops, fft, multinomial, opt, reduction, rng_mrg, sort from theano.gpuarray import (
from .basic_ops import as_gpuarray_variable ctc,
dnn,
extra_ops,
fft,
multinomial,
opt,
reduction,
rng_mrg,
sort,
)
from theano.gpuarray.basic_ops import as_gpuarray_variable
# This is for documentation not to depend on the availability of pygpu # This is for documentation not to depend on the availability of pygpu
from .type import ( from theano.gpuarray.type import (
ContextNotDefined, ContextNotDefined,
GpuArrayConstant, GpuArrayConstant,
GpuArraySharedVariable, GpuArraySharedVariable,
...@@ -160,8 +170,8 @@ def init_dev(dev, name=None, preallocate=None): ...@@ -160,8 +170,8 @@ def init_dev(dev, name=None, preallocate=None):
f" {int(context.free_gmem / MB)} MB are available." f" {int(context.free_gmem / MB)} MB are available."
) )
elif gmem > context.free_gmem - 50 * MB: elif gmem > context.free_gmem - 50 * MB:
print( warnings.warn(
"WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly" "Preallocating too much memory can prevent cudnn and cublas from working properly"
) )
# This will allocate and immediately free an object of size gmem # This will allocate and immediately free an object of size gmem
......
...@@ -2157,6 +2157,7 @@ def consider_constant(x): ...@@ -2157,6 +2157,7 @@ def consider_constant(x):
"consider_constant() is deprecated, use zero_grad() or " "consider_constant() is deprecated, use zero_grad() or "
"disconnected_grad() instead." "disconnected_grad() instead."
), ),
category=DeprecationWarning,
stacklevel=3, stacklevel=3,
) )
......
...@@ -22,7 +22,7 @@ __all__ = [ ...@@ -22,7 +22,7 @@ __all__ = [
] ]
warnings.warn( warnings.warn(
"DEPRECATION: theano.sandbox.blocksparse does not exist anymore," "theano.sandbox.blocksparse does not exist anymore,"
"it has been moved to theano.tensor.nnet.blocksparse.", "it has been moved to theano.tensor.nnet.blocksparse.",
category=DeprecationWarning, category=DeprecationWarning,
) )
import sys from warnings import warn
print( warn(
"DEPRECATION: theano.sandbox.conv no longer provides conv. " "theano.sandbox.conv no longer provides conv. "
"They have been moved to theano.tensor.nnet.conv", "They have been moved to theano.tensor.nnet.conv",
file=sys.stderr, category=DeprecationWarning,
) )
from theano.tensor.nnet.nnet import softsign # noqa from theano.tensor.nnet.nnet import softsign # noqa
import sys from warnings import warn
print( warn(
"DEPRECATION WARNING: softsign was moved from theano.sandbox.softsign to " "softsign was moved from theano.sandbox.softsign to theano.tensor.nnet.nnet ",
"theano.tensor.nnet.nnet ", category=DeprecationWarning,
file=sys.stderr,
) )
...@@ -377,9 +377,8 @@ def scan( ...@@ -377,9 +377,8 @@ def scan(
for i in range(n_outs): for i in range(n_outs):
if outs_info[i] is not None: if outs_info[i] is not None:
if isinstance(outs_info[i], dict): if isinstance(outs_info[i], dict):
# DEPRECATED :
if outs_info[i].get("return_steps", None) is not None: if outs_info[i].get("return_steps", None) is not None:
raise ValueError( raise DeprecationWarning(
"Using `return_steps` has been deprecated. " "Using `return_steps` has been deprecated. "
"Simply select the entries you need using a " "Simply select the entries you need using a "
"subtensor. Scan will optimize memory " "subtensor. Scan will optimize memory "
...@@ -396,12 +395,9 @@ def scan( ...@@ -396,12 +395,9 @@ def scan(
): ):
# ^ no initial state but taps provided # ^ no initial state but taps provided
raise ValueError( raise ValueError(
( "If you are using slices of an output "
"If you are using slices of an output " "you need to provide a initial state "
"you need to provide a initial state " f"for it: {outs_info[i]}"
"for it"
),
outs_info[i],
) )
elif ( elif (
outs_info[i].get("initial", None) is not None outs_info[i].get("initial", None) is not None
......
...@@ -101,14 +101,6 @@ list_opt_slice = [ ...@@ -101,14 +101,6 @@ list_opt_slice = [
] ]
def warning(*msg):
_logger.warning("WARNING theano.scan: " + " ".join(msg))
def info(*msg):
_logger.info("INFO theano.scan: " + " ".join(msg))
@gof.local_optimizer([Scan]) @gof.local_optimizer([Scan])
def remove_constants_and_unused_inputs_scan(fgraph, node): def remove_constants_and_unused_inputs_scan(fgraph, node):
""" """
......
...@@ -202,7 +202,8 @@ def clone( ...@@ -202,7 +202,8 @@ def clone(
""" """
if copy_inputs is not DEPRECATED_ARG: if copy_inputs is not DEPRECATED_ARG:
warnings.warn( warnings.warn(
"In `clone()` function, the argument `copy_inputs` has been deprecated and renamed into `share_inputs`" "In `clone()` function, the argument `copy_inputs` has been deprecated and renamed into `share_inputs`",
category=DeprecationWarning,
) )
assert share_inputs # since we used `copy_inputs` we should have default value for `share_inputs` assert share_inputs # since we used `copy_inputs` we should have default value for `share_inputs`
share_inputs = copy_inputs share_inputs = copy_inputs
......
import sys from warnings import warn
try: try:
...@@ -7,16 +7,10 @@ try: ...@@ -7,16 +7,10 @@ try:
scipy_ver = [int(n) for n in scipy.__version__.split(".")[:2]] scipy_ver = [int(n) for n in scipy.__version__.split(".")[:2]]
enable_sparse = bool(scipy_ver >= [0, 7]) enable_sparse = bool(scipy_ver >= [0, 7])
if not enable_sparse: if not enable_sparse:
sys.stderr.write( warn(f"SciPy version is {scipy.__version__}. We recommend a version >= 0.7.0")
f"WARNING: scipy version = {scipy.__version__}."
" We request version >=0.7.0 for the sparse code as it has"
" bugs fixed in the sparse matrix code.\n"
)
except ImportError: except ImportError:
enable_sparse = False enable_sparse = False
sys.stderr.write( warn("scipy can't be imported." " We disable the sparse matrix code.")
"WARNING: scipy can't be imported." " We disable the sparse matrix code."
)
from theano.sparse.type import * from theano.sparse.type import *
......
...@@ -3,13 +3,11 @@ Classes for handling sparse matrices. ...@@ -3,13 +3,11 @@ Classes for handling sparse matrices.
To read about different sparse formats, see To read about different sparse formats, see
http://www-users.cs.umn.edu/~saad/software/SPARSKIT/paper.ps http://www-users.cs.umn.edu/~saad/software/SPARSKIT/paper.ps
"""
# TODO TODO: Automatic methods for determining best sparse format?
# Automatic methods for determining best sparse format?
import sys """
from warnings import warn
import numpy as np import numpy as np
import scipy.sparse import scipy.sparse
...@@ -907,9 +905,8 @@ class DenseFromSparse(gof.op.Op): ...@@ -907,9 +905,8 @@ class DenseFromSparse(gof.op.Op):
(x,) = inputs (x,) = inputs
(out,) = outputs (out,) = outputs
if _is_dense(x): if _is_dense(x):
print( warn(
("WARNING: You just called DenseFromSparse on a dense matrix."), "You just called DenseFromSparse on a dense matrix.",
file=sys.stderr,
) )
out[0] = x out[0] = x
else: else:
...@@ -2398,10 +2395,8 @@ class MulSD(gof.op.Op): ...@@ -2398,10 +2395,8 @@ class MulSD(gof.op.Op):
z_data[j_idx] *= y[i, j] z_data[j_idx] *= y[i, j]
out[0] = z out[0] = z
else: else:
print( warn(
("WARNING: crappy implementation of MulSD"), "This implementation of MulSD is deficient: {x.format}",
x.format,
file=sys.stderr,
) )
out[0] = type(x)(x.toarray() * y) out[0] = type(x)(x.toarray() * y)
......
...@@ -5455,7 +5455,10 @@ def flatten(x, ndim=None, outdim=None): ...@@ -5455,7 +5455,10 @@ def flatten(x, ndim=None, outdim=None):
elif outdim is not None and ndim is not None: elif outdim is not None and ndim is not None:
raise ValueError("You should only specify ndim") raise ValueError("You should only specify ndim")
elif outdim is not None: elif outdim is not None:
warnings.warn("flatten outdim parameter is deprecated, use ndim instead.") warnings.warn(
"flatten outdim parameter is deprecated, use ndim instead.",
category=DeprecationWarning,
)
ndim = outdim ndim = outdim
# Any input variable can be flattened to have ndim of 1, # Any input variable can be flattened to have ndim of 1,
......
...@@ -554,12 +554,12 @@ class ConvOp(OpenMPOp): ...@@ -554,12 +554,12 @@ class ConvOp(OpenMPOp):
new -= 1 new -= 1
warnstr = ( warnstr = (
"OPTIMISATION WARNING: in ConvOp.__init__() " "In ConvOp.__init__(): "
"unroll_batch(%i) must be 0 or a divisor of" f"unroll_batch({self.unroll_batch}) must be 0 or a divisor of"
" bsize(%i). We revert it to %i. This" f" bsize({self.bsize}). We revert it to {new}. This"
" won't change the result, but may make it slower." " won't change the result, but may make it slower."
) )
_logger.warning(warnstr, self.unroll_batch, self.bsize, new) _logger.warning(warnstr)
self.unroll_batch = new self.unroll_batch = new
...@@ -580,12 +580,12 @@ class ConvOp(OpenMPOp): ...@@ -580,12 +580,12 @@ class ConvOp(OpenMPOp):
new -= 1 new -= 1
warnstr = ( warnstr = (
"OPTIMISATION WARNING: in ConvOp.__init__()" "In ConvOp.__init__(): "
" unroll_kern(%i) should be 0 or a divisor of" f"unroll_kern({self.unroll_kern}) must be 0 or a divisor of"
" nkern(%i). We revert it to %i. This" f" nkern({self.nkern}). We revert it to {new}. This"
" won't change the result, but may make it slower." " won't change the result, but may make it slower."
) )
_logger.warning(warnstr, self.unroll_kern, self.nkern, new) _logger.warning(warnstr)
self.unroll_kern = new self.unroll_kern = new
self.outshp = get_conv_output_shape( self.outshp = get_conv_output_shape(
......
...@@ -440,9 +440,10 @@ class Softmax(Op): ...@@ -440,9 +440,10 @@ class Softmax(Op):
raise ValueError(f"x must be 1-d or 2-d tensor of floats. Got {x.type}") raise ValueError(f"x must be 1-d or 2-d tensor of floats. Got {x.type}")
if x.ndim == 1: if x.ndim == 1:
warnings.warn( warnings.warn(
"DEPRECATION: If x is a vector, Softmax will not automatically pad x " "If x is a vector, Softmax will not automatically pad x "
"anymore in next releases. If you need it, please do it manually. The " "anymore in next releases. If you need it, please do it manually. The "
"vector case is gonna be supported soon and the output will be a vector.", "vector case is gonna be supported soon and the output will be a vector.",
category=PendingDeprecationWarning,
stacklevel=4, stacklevel=4,
) )
x = tt.shape_padleft(x, n_ones=1) x = tt.shape_padleft(x, n_ones=1)
...@@ -638,9 +639,10 @@ class LogSoftmax(Op): ...@@ -638,9 +639,10 @@ class LogSoftmax(Op):
raise ValueError(f"x must be 1-d or 2-d tensor of floats. Got {x.type}") raise ValueError(f"x must be 1-d or 2-d tensor of floats. Got {x.type}")
if x.ndim == 1: if x.ndim == 1:
warnings.warn( warnings.warn(
"DEPRECATION: If x is a vector, LogSoftmax will not automatically pad x " "If x is a vector, LogSoftmax will not automatically pad x "
"anymore in next releases. If you need it, please do it manually. The " "anymore in next releases. If you need it, please do it manually. The "
"vector case is gonna be supported soon and the output will be a vector.", "vector case is gonna be supported soon and the output will be a vector.",
category=PendingDeprecationWarning,
stacklevel=4, stacklevel=4,
) )
x = tt.shape_padleft(x, n_ones=1) x = tt.shape_padleft(x, n_ones=1)
...@@ -1661,8 +1663,7 @@ def local_argmax_pushdown(fgraph, node): ...@@ -1661,8 +1663,7 @@ def local_argmax_pushdown(fgraph, node):
): ):
if theano.config.warn.argmax_pushdown_bug: if theano.config.warn.argmax_pushdown_bug:
logging.getLogger("theano.tensor.nnet.nnet").warn( logging.getLogger("theano.tensor.nnet.nnet").warn(
"WARNING: there " "There was a bug in Theano fixed on May 27th, 2010 in this case."
"was a bug in Theano fixed on May 27th, 2010 in this case."
" I.E. when we take the max of a softplus, softmax, exp, " " I.E. when we take the max of a softplus, softmax, exp, "
"log, tanh, sigmoid, softmax_with_bias op, we were doing " "log, tanh, sigmoid, softmax_with_bias op, we were doing "
"the max of the parent of the input. To remove this " "the max of the parent of the input. To remove this "
......
...@@ -5821,7 +5821,7 @@ def local_sum_prod_div_dimshuffle(fgraph, node): ...@@ -5821,7 +5821,7 @@ def local_sum_prod_div_dimshuffle(fgraph, node):
if compatible_dims: if compatible_dims:
_logger.warning( _logger.warning(
"WARNING: Your current code is fine, but" "Your current code is fine, but"
" Theano versions between " " Theano versions between "
"rev. 3bd9b789f5e8 (2010-06-16) and" "rev. 3bd9b789f5e8 (2010-06-16) and"
" cfc6322e5ad4 (2010-08-03) would " " cfc6322e5ad4 (2010-08-03) would "
...@@ -5876,7 +5876,7 @@ def local_sum_prod_div_dimshuffle(fgraph, node): ...@@ -5876,7 +5876,7 @@ def local_sum_prod_div_dimshuffle(fgraph, node):
node.op, Sum node.op, Sum
): ):
_logger.warning( _logger.warning(
"WARNING: Your current code is fine," "Your current code is fine,"
" but Theano versions between " " but Theano versions between "
"rev. 3bd9b789f5e8 (2010-06-16) and" "rev. 3bd9b789f5e8 (2010-06-16) and"
" cfc6322e5ad4 (2010-08-03) would " " cfc6322e5ad4 (2010-08-03) would "
...@@ -5986,7 +5986,7 @@ def local_op_of_op(fgraph, node): ...@@ -5986,7 +5986,7 @@ def local_op_of_op(fgraph, node):
and len(newaxis) == len(newaxis_old) and len(newaxis) == len(newaxis_old)
): ):
_logger.warning( _logger.warning(
"WARNING (YOUR CURRENT CODE IS FINE): Theano " "(YOUR CURRENT CODE IS FINE): Theano "
"versions between version 9923a40c7b7a and August " "versions between version 9923a40c7b7a and August "
"2nd, 2010 generated bugged code in this case. " "2nd, 2010 generated bugged code in this case. "
"This happens when there are two consecutive sums " "This happens when there are two consecutive sums "
......
"""Define random number Type (`RandomStateType`) and Op (`RandomFunction`).""" """Define random number Type (`RandomStateType`) and Op (`RandomFunction`)."""
import sys
from copy import copy from copy import copy
from functools import reduce from functools import reduce
from warnings import warn
import numpy as np import numpy as np
...@@ -200,10 +199,8 @@ class RandomFunction(gof.Op): ...@@ -200,10 +199,8 @@ class RandomFunction(gof.Op):
assert shape.type.ndim == 1 assert shape.type.ndim == 1
assert (shape.type.dtype == "int64") or (shape.type.dtype == "int32") assert (shape.type.dtype == "int64") or (shape.type.dtype == "int32")
if not isinstance(r.type, RandomStateType): if not isinstance(r.type, RandomStateType):
print( warn("RandomState instances should be in RandomStateType")
"WARNING: RandomState instances should be in RandomStateType",
file=sys.stderr,
)
# the following doesn't work because we want to ignore the # the following doesn't work because we want to ignore the
# broadcastable flags in shape.type # broadcastable flags in shape.type
# assert shape.type == tensor.lvector # assert shape.type == tensor.lvector
...@@ -532,9 +529,9 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None, dtype="int64", prob ...@@ -532,9 +529,9 @@ def binomial(random_state, size=None, n=1, p=0.5, ndim=None, dtype="int64", prob
""" """
if prob is not None: if prob is not None:
p = prob p = prob
print( warn(
"DEPRECATION WARNING: the parameter prob to the binomal fct have been renamed to p to have the same name as np.", "The parameter prob to the binomal fct have been renamed to p to have the same name as np.",
file=sys.stderr, category=DeprecationWarning,
) )
n = tensor.as_tensor_variable(n) n = tensor.as_tensor_variable(n)
p = tensor.as_tensor_variable(p) p = tensor.as_tensor_variable(p)
...@@ -964,9 +961,9 @@ class RandomStreamsBase: ...@@ -964,9 +961,9 @@ class RandomStreamsBase:
""" """
if prob is not None: if prob is not None:
p = prob p = prob
print( warn(
"DEPRECATION WARNING: the parameter prob to the binomal fct have been renamed to p to have the same name as numpy.", "The parameter prob to the binomal fct have been renamed to p to have the same name as numpy.",
file=sys.stderr, category=DeprecationWarning,
) )
return self.gen(binomial, size, n, p, ndim=ndim, dtype=dtype) return self.gen(binomial, size, n, p, ndim=ndim, dtype=dtype)
......
...@@ -93,9 +93,10 @@ def pool_2d( ...@@ -93,9 +93,10 @@ def pool_2d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'ds' parameter is not going to exist" "The 'ds' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'ws'.", " 'ws'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ws = ds ws = ds
...@@ -110,9 +111,10 @@ def pool_2d( ...@@ -110,9 +111,10 @@ def pool_2d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'st' parameter is not going to exist" "The 'st' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'stride'.", " 'stride'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
stride = st stride = st
...@@ -125,9 +127,10 @@ def pool_2d( ...@@ -125,9 +127,10 @@ def pool_2d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'padding' parameter is not going to exist" "The 'padding' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'pad'.", " 'pad'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
pad = padding pad = padding
...@@ -145,6 +148,7 @@ def pool_2d( ...@@ -145,6 +148,7 @@ def pool_2d(
" GPU combination supported is when" " GPU combination supported is when"
" `ws == stride and pad == (0, 0) and mode == 'max'`." " `ws == stride and pad == (0, 0) and mode == 'max'`."
" Otherwise, the convolution will be executed on CPU.", " Otherwise, the convolution will be executed on CPU.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ignore_border = False ignore_border = False
...@@ -210,9 +214,10 @@ def pool_3d( ...@@ -210,9 +214,10 @@ def pool_3d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'ds' parameter is not going to exist" "The 'ds' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'ws'.", " 'ws'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ws = ds ws = ds
...@@ -227,9 +232,10 @@ def pool_3d( ...@@ -227,9 +232,10 @@ def pool_3d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'st' parameter is not going to exist" "The 'st' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'stride'.", " 'stride'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
stride = st stride = st
...@@ -242,9 +248,10 @@ def pool_3d( ...@@ -242,9 +248,10 @@ def pool_3d(
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'padding' parameter is not going to exist" "The 'padding' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'pad'.", " 'pad'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
pad = padding pad = padding
...@@ -262,6 +269,7 @@ def pool_3d( ...@@ -262,6 +269,7 @@ def pool_3d(
" GPU combination supported is when" " GPU combination supported is when"
" `ws == stride and pad == (0, 0, 0) and mode == 'max'`." " `ws == stride and pad == (0, 0, 0) and mode == 'max'`."
" Otherwise, the convolution will be executed on CPU.", " Otherwise, the convolution will be executed on CPU.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ignore_border = False ignore_border = False
...@@ -387,9 +395,10 @@ class Pool(OpenMPOp): ...@@ -387,9 +395,10 @@ class Pool(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'ds' parameter is not going to exist" "The 'ds' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'ws'.", " 'ws'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ws = ds ws = ds
...@@ -404,9 +413,10 @@ class Pool(OpenMPOp): ...@@ -404,9 +413,10 @@ class Pool(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'st' parameter is not going to exist" "The 'st' parameter is not going to exist"
" anymore as it is going to be replaced by the parameter" " anymore as it is going to be replaced by the parameter"
" 'stride'.", " 'stride'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
stride = st stride = st
...@@ -420,9 +430,10 @@ class Pool(OpenMPOp): ...@@ -420,9 +430,10 @@ class Pool(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'padding' parameter is not going to" "The 'padding' parameter is not going to"
" exist anymore as it is going to be replaced by the" " exist anymore as it is going to be replaced by the"
" parameter 'pad'.", " parameter 'pad'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
pad = padding pad = padding
...@@ -1032,9 +1043,10 @@ class PoolGrad(OpenMPOp): ...@@ -1032,9 +1043,10 @@ class PoolGrad(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'ds' parameter in PoolGrad is not going" "The 'ds' parameter in PoolGrad is not going"
" to exist anymore as it is going to be replaced by the" " to exist anymore as it is going to be replaced by the"
" parameter 'ws'.", " parameter 'ws'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
ws = ds ws = ds
...@@ -1049,9 +1061,10 @@ class PoolGrad(OpenMPOp): ...@@ -1049,9 +1061,10 @@ class PoolGrad(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'st' parameter in PoolGrad is not going" "The 'st' parameter in PoolGrad is not going"
" to exist anymore as it is going to be replaced by the" " to exist anymore as it is going to be replaced by the"
" parameter 'stride'.", " parameter 'stride'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
stride = st stride = st
...@@ -1064,9 +1077,10 @@ class PoolGrad(OpenMPOp): ...@@ -1064,9 +1077,10 @@ class PoolGrad(OpenMPOp):
) )
else: else:
warnings.warn( warnings.warn(
"DEPRECATION: the 'padding' parameter in PoolGrad is not" "The 'padding' parameter in PoolGrad is not"
" going to exist anymore as it is going to be replaced" " going to exist anymore as it is going to be replaced"
" by the parameter 'pad'.", " by the parameter 'pad'.",
category=DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
pad = padding pad = padding
......
...@@ -55,9 +55,10 @@ class TensorType(Type): ...@@ -55,9 +55,10 @@ class TensorType(Type):
self.sparse_grad = sparse_grad self.sparse_grad = sparse_grad
if sparse_grad: if sparse_grad:
warnings.warn( warnings.warn(
"DEPRECATION WARNING: You use an old interface to" "You use an old interface to"
" AdvancedSubtensor1 sparse_grad. Now use" " AdvancedSubtensor1 sparse_grad. Now use"
" theano.sparse_grad(a_tensor[an_int_vector])." " theano.sparse_grad(a_tensor[an_int_vector]).",
category=DeprecationWarning,
) )
def clone(self, dtype=None, broadcastable=None): def clone(self, dtype=None, broadcastable=None):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论