Numpy.zeros_like — NumPy V1.23 Manual

Skip to main content Back to top Ctrl+K
  • User Guide
  • API reference
  • Building from source
  • Development
  • Release notes
  • Learn
  • NEPs
Choose version
  • GitHub

Section Navigation

  • NumPy’s module structure
  • Array objects
  • Universal functions (ufunc)
  • Routines and objects by topic
    • Constants
    • Array creation routines
      • numpy.empty
      • numpy.empty_like
      • numpy.eye
      • numpy.identity
      • numpy.ones
      • numpy.ones_like
      • numpy.zeros
      • numpy.zeros_like
      • numpy.full
      • numpy.full_like
      • numpy.array
      • numpy.asarray
      • numpy.asanyarray
      • numpy.ascontiguousarray
      • numpy.asmatrix
      • numpy.astype
      • numpy.copy
      • numpy.frombuffer
      • numpy.from_dlpack
      • numpy.fromfile
      • numpy.fromfunction
      • numpy.fromiter
      • numpy.fromstring
      • numpy.loadtxt
      • numpy.rec.array
      • numpy.rec.fromarrays
      • numpy.rec.fromrecords
      • numpy.rec.fromstring
      • numpy.rec.fromfile
      • numpy.char.array
      • numpy.char.asarray
      • numpy.arange
      • numpy.linspace
      • numpy.logspace
      • numpy.geomspace
      • numpy.meshgrid
      • numpy.mgrid
      • numpy.ogrid
      • numpy.diag
      • numpy.diagflat
      • numpy.tri
      • numpy.tril
      • numpy.triu
      • numpy.vander
      • numpy.bmat
    • Array manipulation routines
    • Bit-wise operations
    • String functionality
    • Datetime support functions
    • Data type routines
    • Mathematical functions with automatic domain
    • Floating point error handling
    • Exceptions and Warnings
    • Discrete Fourier Transform
    • Functional programming
    • Input and output
    • Indexing routines
    • Linear algebra
    • Logic functions
    • Masked array operations
    • Mathematical functions
    • Miscellaneous routines
    • Polynomials
    • Random sampling
    • Set routines
    • Sorting, searching, and counting
    • Statistics
    • Test support
    • Window functions
  • Typing (numpy.typing)
  • Packaging
  • NumPy C-API
  • Array API standard compatibility
  • CPU/SIMD optimizations
  • Thread Safety
  • Global Configuration Options
  • NumPy security
  • Status of numpy.distutils and migration advice
  • numpy.distutils user guide
  • NumPy and SWIG
  • NumPy reference
  • Routines and objects by topic
  • Array creation routines
  • numpy.zeros_like
numpy.zeros_like# numpy.zeros_like(a, dtype=None, order='K', subok=True, shape=None, *, device=None)[source]#

Return an array of zeros with the same shape and type as a given array.

Parameters: aarray_like

The shape and data-type of a define these same attributes of the returned array.

dtypedata-type, optional

Overrides the data type of the result.

order{‘C’, ‘F’, ‘A’, or ‘K’}, optional

Overrides the memory layout of the result. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.

subokbool, optional.

If True, then the newly created array will use the sub-class type of a, otherwise it will be a base-class array. Defaults to True.

shapeint or sequence of ints, optional.

Overrides the shape of the result. If order=’K’ and the number of dimensions is unchanged, will try to keep order, otherwise, order=’C’ is implied.

devicestr, optional

The device on which to place the created array. Default: None. For Array-API interoperability only, so must be "cpu" if passed.

New in version 2.0.0.

Returns: outndarray

Array of zeros with the same shape and type as a.

See also

empty_like

Return an empty array with shape and type of input.

ones_like

Return an array of ones with shape and type of input.

full_like

Return a new array with shape of input filled with value.

zeros

Return a new array setting values to zero.

Examples

Try it in your browser! >>> importnumpyasnp >>> x = np.arange(6) >>> x = x.reshape((2, 3)) >>> x array([[0, 1, 2], [3, 4, 5]]) >>> np.zeros_like(x) array([[0, 0, 0], [0, 0, 0]]) >>> y = np.arange(3, dtype=float) >>> y array([0., 1., 2.]) >>> np.zeros_like(y) array([0., 0., 0.]) Go BackOpen In Tab On this page
  • zeros_like

Từ khóa » Np.zeros_like Là Gì