chainer.as_variable¶
-
chainer.as_variable(obj)[source]¶ Converts an array or a variable into
Variable.This is a convenient function to get a
Variableobject transparently from a raw array or a variable.Note that this function should only be used for type consistency (i.e., to enforce the return value of an API having type
Variable). Therequires_gradflag is kept as is; ifobjis a raw array, the newly created variable hasrequires_grad = False. In order to make a variable w.r.t. which you want to compute the gradient, you should useVariabledirectly.Parameters: obj (N-dimensional array or ~chainer.Variable) – An array or a variable that you want to convert to Variable.Returns: A variable converted from obj. Ifobjis a raw array, this is a newVariableobject that wraps the array. Ifobjis already aVariableobject, this function returnsobjas is.Return type: Variable