Lines Matching full:tensor
5 torch.Tensor
8 A :class:`torch.Tensor` is a multi-dimensional matrix containing elements of
15 Torch defines tensor types with the following data types:
69 Data type CPU tensor GPU tensor
85 :class:`torch.Tensor` constructor is an alias for the default tensor type
91 A tensor can be constructed from a Python :class:`list` or sequence using the
92 :func:`torch.tensor` constructor:
96 >>> torch.tensor([[1., -1.], [1., -1.]])
97 tensor([[ 1.0000, -1.0000],
99 >>> torch.tensor(np.array([[1, 2, 3], [4, 5, 6]]))
100 tensor([[ 1, 2, 3],
105 :func:`torch.tensor` always copies :attr:`data`. If you have a Tensor
107 :meth:`~torch.Tensor.requires_grad_` or
108 :meth:`~torch.Tensor.detach` to avoid a copy.
112 A tensor of specific data type can be constructed by passing a
114 constructor or tensor creation op:
119 tensor([[ 0, 0, 0, 0],
123 tensor([[ 1.0000, 1.0000, 1.0000, 1.0000],
126 For more information about building Tensors, see :ref:`tensor-creation-ops`
129 The contents of a tensor can be accessed and modified using Python's indexing
134 >>> x = torch.tensor([[1, 2, 3], [4, 5, 6]])
136 tensor(6)
139 tensor([[ 1, 8, 3],
142 Use :meth:`torch.Tensor.item` to get a Python number from a tensor containing a
147 >>> x = torch.tensor([[1]])
149 tensor([[ 1]])
152 >>> x = torch.tensor(2.5)
154 tensor(2.5000)
160 A tensor can be created with :attr:`requires_grad=True` so that
165 >>> x = torch.tensor([[1., -1.], [1., 1.]], requires_grad=True)
169 tensor([[ 2.0000, -2.0000],
172 Each tensor has an associated :class:`torch.Storage`, which holds its data.
173 The tensor class also provides multi-dimensional, `strided <https://en.wikipedia.org/wiki/Stride_of…
177 For more information on tensor views, see :ref:`tensor-view-doc`.
181 :class:`torch.layout` attributes of a :class:`torch.Tensor`, see
182 :ref:`tensor-attributes-doc`.
185 Methods which mutate a tensor are marked with an underscore suffix.
187 in-place and returns the modified tensor, while :func:`torch.FloatTensor.abs`
188 computes the result in a new tensor.
191 To change an existing tensor's :class:`torch.device` and/or :class:`torch.dtype`, consider using
192 :meth:`~torch.Tensor.to` method on the tensor.
195 Current implementation of :class:`torch.Tensor` introduces memory overhead,
200 Tensor class reference
203 .. class:: Tensor()
205 There are a few main ways to create a tensor, depending on your use case.
207 - To create a tensor with pre-existing data, use :func:`torch.tensor`.
208 - To create a tensor with specific size, use ``torch.*`` tensor creation
209 ops (see :ref:`tensor-creation-ops`).
210 - To create a tensor with the same size (and similar types) as another tensor,
211 use ``torch.*_like`` tensor creation ops
212 (see :ref:`tensor-creation-ops`).
213 - To create a tensor with similar type but different size as another tensor,
214 use ``tensor.new_*`` creation ops.
215 - There is a legacy constructor ``torch.Tensor`` whose use is discouraged.
216 Use :func:`torch.tensor` instead.
218 .. method:: Tensor.__init__(self, data)
220 This constructor is deprecated, we recommend using :func:`torch.tensor` instead.
223 * If ``data`` is a Tensor, returns an alias to the original Tensor. Unlike
224 :func:`torch.tensor`, this tracks autograd and will propagate gradients to
225 the original Tensor. ``device`` kwarg is not supported for this ``data`` type.
227 * If ``data`` is a sequence or nested sequence, create a tensor of the default
230 :func:`torch.tensor` in that this constructor will always construct a float
231 tensor, even if the inputs are all integers.
233 * If ``data`` is a :class:`torch.Size`, returns an empty tensor of that size.
236 the returned tensor. We recommend using :func:`torch.tensor` which provides this
240 data (array_like): The tensor to construct from.
243 device (:class:`torch.device`, optional): the desired device of returned tensor.
244 Default: if None, same :class:`torch.device` as this tensor.
247 .. autoattribute:: Tensor.T
248 .. autoattribute:: Tensor.H
249 .. autoattribute:: Tensor.mT
250 .. autoattribute:: Tensor.mH
256 Tensor.new_tensor
257 Tensor.new_full
258 Tensor.new_empty
259 Tensor.new_ones
260 Tensor.new_zeros
262 Tensor.is_cuda
263 Tensor.is_quantized
264 Tensor.is_meta
265 Tensor.device
266 Tensor.grad
267 Tensor.ndim
268 Tensor.real
269 Tensor.imag
270 Tensor.nbytes
271 Tensor.itemsize
273 Tensor.abs
274 Tensor.abs_
275 Tensor.absolute
276 Tensor.absolute_
277 Tensor.acos
278 Tensor.acos_
279 Tensor.arccos
280 Tensor.arccos_
281 Tensor.add
282 Tensor.add_
283 Tensor.addbmm
284 Tensor.addbmm_
285 Tensor.addcdiv
286 Tensor.addcdiv_
287 Tensor.addcmul
288 Tensor.addcmul_
289 Tensor.addmm
290 Tensor.addmm_
291 Tensor.sspaddmm
292 Tensor.addmv
293 Tensor.addmv_
294 Tensor.addr
295 Tensor.addr_
296 Tensor.adjoint
297 Tensor.allclose
298 Tensor.amax
299 Tensor.amin
300 Tensor.aminmax
301 Tensor.angle
302 Tensor.apply_
303 Tensor.argmax
304 Tensor.argmin
305 Tensor.argsort
306 Tensor.argwhere
307 Tensor.asin
308 Tensor.asin_
309 Tensor.arcsin
310 Tensor.arcsin_
311 Tensor.as_strided
312 Tensor.atan
313 Tensor.atan_
314 Tensor.arctan
315 Tensor.arctan_
316 Tensor.atan2
317 Tensor.atan2_
318 Tensor.arctan2
319 Tensor.arctan2_
320 Tensor.all
321 Tensor.any
322 Tensor.backward
323 Tensor.baddbmm
324 Tensor.baddbmm_
325 Tensor.bernoulli
326 Tensor.bernoulli_
327 Tensor.bfloat16
328 Tensor.bincount
329 Tensor.bitwise_not
330 Tensor.bitwise_not_
331 Tensor.bitwise_and
332 Tensor.bitwise_and_
333 Tensor.bitwise_or
334 Tensor.bitwise_or_
335 Tensor.bitwise_xor
336 Tensor.bitwise_xor_
337 Tensor.bitwise_left_shift
338 Tensor.bitwise_left_shift_
339 Tensor.bitwise_right_shift
340 Tensor.bitwise_right_shift_
341 Tensor.bmm
342 Tensor.bool
343 Tensor.byte
344 Tensor.broadcast_to
345 Tensor.cauchy_
346 Tensor.ceil
347 Tensor.ceil_
348 Tensor.char
349 Tensor.cholesky
350 Tensor.cholesky_inverse
351 Tensor.cholesky_solve
352 Tensor.chunk
353 Tensor.clamp
354 Tensor.clamp_
355 Tensor.clip
356 Tensor.clip_
357 Tensor.clone
358 Tensor.contiguous
359 Tensor.copy_
360 Tensor.conj
361 Tensor.conj_physical
362 Tensor.conj_physical_
363 Tensor.resolve_conj
364 Tensor.resolve_neg
365 Tensor.copysign
366 Tensor.copysign_
367 Tensor.cos
368 Tensor.cos_
369 Tensor.cosh
370 Tensor.cosh_
371 Tensor.corrcoef
372 Tensor.count_nonzero
373 Tensor.cov
374 Tensor.acosh
375 Tensor.acosh_
376 Tensor.arccosh
377 Tensor.arccosh_
378 Tensor.cpu
379 Tensor.cross
380 Tensor.cuda
381 Tensor.logcumsumexp
382 Tensor.cummax
383 Tensor.cummin
384 Tensor.cumprod
385 Tensor.cumprod_
386 Tensor.cumsum
387 Tensor.cumsum_
388 Tensor.chalf
389 Tensor.cfloat
390 Tensor.cdouble
391 Tensor.data_ptr
392 Tensor.deg2rad
393 Tensor.dequantize
394 Tensor.det
395 Tensor.dense_dim
396 Tensor.detach
397 Tensor.detach_
398 Tensor.diag
399 Tensor.diag_embed
400 Tensor.diagflat
401 Tensor.diagonal
402 Tensor.diagonal_scatter
403 Tensor.fill_diagonal_
404 Tensor.fmax
405 Tensor.fmin
406 Tensor.diff
407 Tensor.digamma
408 Tensor.digamma_
409 Tensor.dim
410 Tensor.dim_order
411 Tensor.dist
412 Tensor.div
413 Tensor.div_
414 Tensor.divide
415 Tensor.divide_
416 Tensor.dot
417 Tensor.double
418 Tensor.dsplit
419 Tensor.element_size
420 Tensor.eq
421 Tensor.eq_
422 Tensor.equal
423 Tensor.erf
424 Tensor.erf_
425 Tensor.erfc
426 Tensor.erfc_
427 Tensor.erfinv
428 Tensor.erfinv_
429 Tensor.exp
430 Tensor.exp_
431 Tensor.expm1
432 Tensor.expm1_
433 Tensor.expand
434 Tensor.expand_as
435 Tensor.exponential_
436 Tensor.fix
437 Tensor.fix_
438 Tensor.fill_
439 Tensor.flatten
440 Tensor.flip
441 Tensor.fliplr
442 Tensor.flipud
443 Tensor.float
444 Tensor.float_power
445 Tensor.float_power_
446 Tensor.floor
447 Tensor.floor_
448 Tensor.floor_divide
449 Tensor.floor_divide_
450 Tensor.fmod
451 Tensor.fmod_
452 Tensor.frac
453 Tensor.frac_
454 Tensor.frexp
455 Tensor.gather
456 Tensor.gcd
457 Tensor.gcd_
458 Tensor.ge
459 Tensor.ge_
460 Tensor.greater_equal
461 Tensor.greater_equal_
462 Tensor.geometric_
463 Tensor.geqrf
464 Tensor.ger
465 Tensor.get_device
466 Tensor.gt
467 Tensor.gt_
468 Tensor.greater
469 Tensor.greater_
470 Tensor.half
471 Tensor.hardshrink
472 Tensor.heaviside
473 Tensor.histc
474 Tensor.histogram
475 Tensor.hsplit
476 Tensor.hypot
477 Tensor.hypot_
478 Tensor.i0
479 Tensor.i0_
480 Tensor.igamma
481 Tensor.igamma_
482 Tensor.igammac
483 Tensor.igammac_
484 Tensor.index_add_
485 Tensor.index_add
486 Tensor.index_copy_
487 Tensor.index_copy
488 Tensor.index_fill_
489 Tensor.index_fill
490 Tensor.index_put_
491 Tensor.index_put
492 Tensor.index_reduce_
493 Tensor.index_reduce
494 Tensor.index_select
495 Tensor.indices
496 Tensor.inner
497 Tensor.int
498 Tensor.int_repr
499 Tensor.inverse
500 Tensor.isclose
501 Tensor.isfinite
502 Tensor.isinf
503 Tensor.isposinf
504 Tensor.isneginf
505 Tensor.isnan
506 Tensor.is_contiguous
507 Tensor.is_complex
508 Tensor.is_conj
509 Tensor.is_floating_point
510 Tensor.is_inference
511 Tensor.is_leaf
512 Tensor.is_pinned
513 Tensor.is_set_to
514 Tensor.is_shared
515 Tensor.is_signed
516 Tensor.is_sparse
517 Tensor.istft
518 Tensor.isreal
519 Tensor.item
520 Tensor.kthvalue
521 Tensor.lcm
522 Tensor.lcm_
523 Tensor.ldexp
524 Tensor.ldexp_
525 Tensor.le
526 Tensor.le_
527 Tensor.less_equal
528 Tensor.less_equal_
529 Tensor.lerp
530 Tensor.lerp_
531 Tensor.lgamma
532 Tensor.lgamma_
533 Tensor.log
534 Tensor.log_
535 Tensor.logdet
536 Tensor.log10
537 Tensor.log10_
538 Tensor.log1p
539 Tensor.log1p_
540 Tensor.log2
541 Tensor.log2_
542 Tensor.log_normal_
543 Tensor.logaddexp
544 Tensor.logaddexp2
545 Tensor.logsumexp
546 Tensor.logical_and
547 Tensor.logical_and_
548 Tensor.logical_not
549 Tensor.logical_not_
550 Tensor.logical_or
551 Tensor.logical_or_
552 Tensor.logical_xor
553 Tensor.logical_xor_
554 Tensor.logit
555 Tensor.logit_
556 Tensor.long
557 Tensor.lt
558 Tensor.lt_
559 Tensor.less
560 Tensor.less_
561 Tensor.lu
562 Tensor.lu_solve
563 Tensor.as_subclass
564 Tensor.map_
565 Tensor.masked_scatter_
566 Tensor.masked_scatter
567 Tensor.masked_fill_
568 Tensor.masked_fill
569 Tensor.masked_select
570 Tensor.matmul
571 Tensor.matrix_power
572 Tensor.matrix_exp
573 Tensor.max
574 Tensor.maximum
575 Tensor.mean
576 Tensor.module_load
577 Tensor.nanmean
578 Tensor.median
579 Tensor.nanmedian
580 Tensor.min
581 Tensor.minimum
582 Tensor.mm
583 Tensor.smm
584 Tensor.mode
585 Tensor.movedim
586 Tensor.moveaxis
587 Tensor.msort
588 Tensor.mul
589 Tensor.mul_
590 Tensor.multiply
591 Tensor.multiply_
592 Tensor.multinomial
593 Tensor.mv
594 Tensor.mvlgamma
595 Tensor.mvlgamma_
596 Tensor.nansum
597 Tensor.narrow
598 Tensor.narrow_copy
599 Tensor.ndimension
600 Tensor.nan_to_num
601 Tensor.nan_to_num_
602 Tensor.ne
603 Tensor.ne_
604 Tensor.not_equal
605 Tensor.not_equal_
606 Tensor.neg
607 Tensor.neg_
608 Tensor.negative
609 Tensor.negative_
610 Tensor.nelement
611 Tensor.nextafter
612 Tensor.nextafter_
613 Tensor.nonzero
614 Tensor.norm
615 Tensor.normal_
616 Tensor.numel
617 Tensor.numpy
618 Tensor.orgqr
619 Tensor.ormqr
620 Tensor.outer
621 Tensor.permute
622 Tensor.pin_memory
623 Tensor.pinverse
624 Tensor.polygamma
625 Tensor.polygamma_
626 Tensor.positive
627 Tensor.pow
628 Tensor.pow_
629 Tensor.prod
630 Tensor.put_
631 Tensor.qr
632 Tensor.qscheme
633 Tensor.quantile
634 Tensor.nanquantile
635 Tensor.q_scale
636 Tensor.q_zero_point
637 Tensor.q_per_channel_scales
638 Tensor.q_per_channel_zero_points
639 Tensor.q_per_channel_axis
640 Tensor.rad2deg
641 Tensor.random_
642 Tensor.ravel
643 Tensor.reciprocal
644 Tensor.reciprocal_
645 Tensor.record_stream
646 Tensor.register_hook
647 Tensor.register_post_accumulate_grad_hook
648 Tensor.remainder
649 Tensor.remainder_
650 Tensor.renorm
651 Tensor.renorm_
652 Tensor.repeat
653 Tensor.repeat_interleave
654 Tensor.requires_grad
655 Tensor.requires_grad_
656 Tensor.reshape
657 Tensor.reshape_as
658 Tensor.resize_
659 Tensor.resize_as_
660 Tensor.retain_grad
661 Tensor.retains_grad
662 Tensor.roll
663 Tensor.rot90
664 Tensor.round
665 Tensor.round_
666 Tensor.rsqrt
667 Tensor.rsqrt_
668 Tensor.scatter
669 Tensor.scatter_
670 Tensor.scatter_add_
671 Tensor.scatter_add
672 Tensor.scatter_reduce_
673 Tensor.scatter_reduce
674 Tensor.select
675 Tensor.select_scatter
676 Tensor.set_
677 Tensor.share_memory_
678 Tensor.short
679 Tensor.sigmoid
680 Tensor.sigmoid_
681 Tensor.sign
682 Tensor.sign_
683 Tensor.signbit
684 Tensor.sgn
685 Tensor.sgn_
686 Tensor.sin
687 Tensor.sin_
688 Tensor.sinc
689 Tensor.sinc_
690 Tensor.sinh
691 Tensor.sinh_
692 Tensor.asinh
693 Tensor.asinh_
694 Tensor.arcsinh
695 Tensor.arcsinh_
696 Tensor.shape
697 Tensor.size
698 Tensor.slogdet
699 Tensor.slice_scatter
700 Tensor.softmax
701 Tensor.sort
702 Tensor.split
703 Tensor.sparse_mask
704 Tensor.sparse_dim
705 Tensor.sqrt
706 Tensor.sqrt_
707 Tensor.square
708 Tensor.square_
709 Tensor.squeeze
710 Tensor.squeeze_
711 Tensor.std
712 Tensor.stft
713 Tensor.storage
714 Tensor.untyped_storage
715 Tensor.storage_offset
716 Tensor.storage_type
717 Tensor.stride
718 Tensor.sub
719 Tensor.sub_
720 Tensor.subtract
721 Tensor.subtract_
722 Tensor.sum
723 Tensor.sum_to_size
724 Tensor.svd
725 Tensor.swapaxes
726 Tensor.swapdims
727 Tensor.t
728 Tensor.t_
729 Tensor.tensor_split
730 Tensor.tile
731 Tensor.to
732 Tensor.to_mkldnn
733 Tensor.take
734 Tensor.take_along_dim
735 Tensor.tan
736 Tensor.tan_
737 Tensor.tanh
738 Tensor.tanh_
739 Tensor.atanh
740 Tensor.atanh_
741 Tensor.arctanh
742 Tensor.arctanh_
743 Tensor.tolist
744 Tensor.topk
745 Tensor.to_dense
746 Tensor.to_sparse
747 Tensor.to_sparse_csr
748 Tensor.to_sparse_csc
749 Tensor.to_sparse_bsr
750 Tensor.to_sparse_bsc
751 Tensor.trace
752 Tensor.transpose
753 Tensor.transpose_
754 Tensor.triangular_solve
755 Tensor.tril
756 Tensor.tril_
757 Tensor.triu
758 Tensor.triu_
759 Tensor.true_divide
760 Tensor.true_divide_
761 Tensor.trunc
762 Tensor.trunc_
763 Tensor.type
764 Tensor.type_as
765 Tensor.unbind
766 Tensor.unflatten
767 Tensor.unfold
768 Tensor.uniform_
769 Tensor.unique
770 Tensor.unique_consecutive
771 Tensor.unsqueeze
772 Tensor.unsqueeze_
773 Tensor.values
774 Tensor.var
775 Tensor.vdot
776 Tensor.view
777 Tensor.view_as
778 Tensor.vsplit
779 Tensor.where
780 Tensor.xlogy
781 Tensor.xlogy_
782 Tensor.xpu
783 Tensor.zero_