Skip to content

Use Variable.array instead of Variable.data #335

@muupan

Description

@muupan

Since Chainer v3, chainer.Variable has the array property that is equivalent to the data property. It is better to use array because it can catch a bug of unintentionally accessing numpy.ndarray.data.

https://docs.chainer.org/en/stable/reference/generated/chainer.Variable.html#chainer.Variable.data

Note that using this attribute directly is discouraged; use array instead. Using array, you can find an error earlier when your code mixes up Variable and ndarray because ndarray does not have an attribute .array while it has .data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions