{"id":47563,"date":"2026-11-23T22:06:05","date_gmt":"2026-11-23T22:06:05","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=47563"},"modified":"2026-11-23T22:06:05","modified_gmt":"2026-11-23T22:06:05","slug":"pytorch-lab-2-pytorch-tensors","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/pytorch-lab-2-pytorch-tensors\/","title":{"rendered":"PyTorch Lab &#8211; 2 &#8211; Pytorch Tensors"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This lab covers the core PyTorch tensor operations: creating tensors, choosing data types, in-place and out-of-place operations, indexing and slicing, splitting and joining, views and reshaping, and sorting. The notebook above was recorded on PyTorch 1.0.1. The sections below explain what each part does and point out where current PyTorch 2.x behaves differently. They also include an updated version of the code and fixes for the errors the notebook shows on purpose.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/dd06633371a9f52ad25bf92f3163e41c.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Setting up the lab environment<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The notebook ran on PyTorch 1.0.1 under Anaconda with Python 3.7. Both versions are long out of support. Use a recent Python 3 and the current PyTorch release in a virtual environment. The CPU build is enough for every cell in this lab.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">python3 -m venv torch-lab\nsource torch-lab\/bin\/activate\npip install torch jupyter\npython -c <span class=\"hljs-string\">\"import torch; print(torch.__version__, torch.cuda.is_available())\"<\/span>\njupyter notebook<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> For a GPU build, take the exact install command from the selector on the official PyTorch website. The right wheel depends on your CUDA version. A plain <code>pip install torch<\/code> on Linux may install a different build than the one you need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Legacy calls in the notebook and their modern equivalents<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Several calls in the example above still run, but they use the old type-specific constructors (<code>torch.Tensor<\/code>, <code>torch.ShortTensor<\/code>, <code>torch.FloatTensor<\/code>, <code>.type(torch.IntTensor)<\/code>). Current PyTorch code sets the type with the <code>dtype<\/code> argument and builds tensors with factory functions. These are clearer, and they also accept <code>device<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Notebook code<\/th><th>Recommended today<\/th><th>Why<\/th><\/tr><\/thead><tbody><tr><td><code>torch.Tensor([[1,2,3],[4,5,6]])<\/code><\/td><td><code>torch.tensor([[1,2,3],[4,5,6]], dtype=torch.float32)<\/code><\/td><td><code>torch.tensor<\/code> infers or accepts an explicit dtype. <code>torch.Tensor<\/code> always uses the default float type.<\/td><\/tr><tr><td><code>torch.Tensor(2, 2)<\/code><\/td><td><code>torch.empty(2, 2)<\/code><\/td><td>Makes it explicit that the memory is uninitialised.<\/td><\/tr><tr><td><code>torch.tensor([5, 3]).type(torch.IntTensor)<\/code><\/td><td><code>torch.tensor([5, 3], dtype=torch.int32)<\/code><\/td><td>Creates the tensor once instead of creating it and then casting.<\/td><\/tr><tr><td><code>torch.ShortTensor([1.0, 2.0, 3.0])<\/code><\/td><td><code>torch.tensor([1, 2, 3], dtype=torch.int16)<\/code><\/td><td>Legacy typed constructors are discouraged.<\/td><\/tr><tr><td><code>.type(torch.half)<\/code><\/td><td><code>.to(torch.float16)<\/code> or <code>.half()<\/code><\/td><td><code>.to()<\/code> handles both dtype and device.<\/td><\/tr><tr><td><code>torch.FloatTensor([...])<\/code><\/td><td><code>torch.tensor([...], dtype=torch.float32)<\/code><\/td><td>Same reason as above.<\/td><\/tr><tr><td><code>torch.full((2, 6), fill_value=10)<\/code><\/td><td><code>torch.full((2, 6), 10.0)<\/code> or pass <code>dtype=<\/code><\/td><td>Current versions infer the dtype from the fill value, so an integer <code>10<\/code> gives an <code>int64<\/code> tensor, not the float output shown above.<\/td><\/tr><tr><td><code>sparse_tensor.data<\/code><\/td><td><code>sparse_tensor<\/code> or <code>sparse_tensor.to_dense()<\/code><\/td><td><code>.data<\/code> bypasses autograd tracking and should not be used for inspection.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Updated lab code for current PyTorch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This version of the creation cells runs cleanly on current PyTorch. It fixes the seed so random values are repeatable. It also leaves the default dtype at <code>float32<\/code>, which is what most models and GPUs expect.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import torch\n\n<span class=\"hljs-keyword\">print<\/span>(torch.__version__)\ntorch.manual_seed(<span class=\"hljs-number\">0<\/span>)                      <span class=\"hljs-comment\"># repeatable random values<\/span>\n<span class=\"hljs-keyword\">print<\/span>(torch.get_default_dtype())          <span class=\"hljs-comment\"># torch.float32<\/span>\n\nt = torch.tensor(&#91;&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>], &#91;<span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>]], dtype=torch.float32)\n<span class=\"hljs-keyword\">print<\/span>(t.shape, t.dtype, t.numel())        <span class=\"hljs-comment\"># torch.Size(&#91;2, 3]) torch.float32 6<\/span>\n\n<span class=\"hljs-keyword\">empty<\/span>  = torch.<span class=\"hljs-keyword\">empty<\/span>(<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">2<\/span>)                <span class=\"hljs-comment\"># garbage values, never read before writing<\/span>\nrand   = torch.rand(<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">2<\/span>)                 <span class=\"hljs-comment\"># uniform &#91;0, 1)<\/span>\nt_int  = torch.tensor(&#91;<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">3<\/span>], dtype=torch.int32)\nt_i16  = torch.tensor(&#91;<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>], dtype=torch.int16)\nt_half = torch.tensor(&#91;<span class=\"hljs-number\">1.0<\/span>, <span class=\"hljs-number\">2.0<\/span>, <span class=\"hljs-number\">3.0<\/span>], dtype=torch.float16)\n\nfull_f = torch.full((<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">6<\/span>), <span class=\"hljs-number\">10.0<\/span>)         <span class=\"hljs-comment\"># float32<\/span>\nfull_i = torch.full((<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">6<\/span>), <span class=\"hljs-number\">10<\/span>)           <span class=\"hljs-comment\"># int64 on current versions<\/span>\n\nones  = torch.ones(<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">4<\/span>, dtype=torch.int32)\nzeros = torch.zeros_like(ones)            <span class=\"hljs-comment\"># same shape, dtype and device as ones<\/span>\neye   = torch.eye(<span class=\"hljs-number\">5<\/span>)\n\n<span class=\"hljs-keyword\">print<\/span>(torch.nonzero(eye))                 <span class=\"hljs-comment\"># shape (5, 2): one &#91;row, col] per non-zero<\/span>\nrows, cols = torch.nonzero(eye, as_tuple=<span class=\"hljs-keyword\">True<\/span>)  <span class=\"hljs-comment\"># tuple form, usable for indexing<\/span>\n\ni = torch.tensor(&#91;&#91;<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">1<\/span>],              <span class=\"hljs-comment\"># row indices<\/span>\n                  &#91;<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">0<\/span>]])             <span class=\"hljs-comment\"># column indices<\/span>\nv = torch.tensor(&#91;<span class=\"hljs-number\">3.0<\/span>, <span class=\"hljs-number\">4.0<\/span>, <span class=\"hljs-number\">5.0<\/span>])\nsparse = torch.sparse_coo_tensor(i, v, (<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">5<\/span>))\n<span class=\"hljs-keyword\">print<\/span>(sparse.to_dense())<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The dense form of the sparse tensor makes the coordinate format easy to check. Each column of <code>i<\/code> is one (row, col) position, and the matching entry in <code>v<\/code> is the value stored there:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">tensor<\/span>(<span class=\"hljs-selector-attr\">&#91;&#91;0., 0., 3., 0., 0.]<\/span>,\n        <span class=\"hljs-selector-attr\">&#91;5., 0., 4., 0., 0.]<\/span>])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">What the default dtype controls<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>torch.set_default_dtype()<\/code> changes the type used when PyTorch has to pick a floating-point type itself, for example in <code>torch.rand<\/code>, <code>torch.eye<\/code>, <code>torch.Tensor(...)<\/code> and <code>torch.tensor([1.0, 2.0])<\/code>. Integer tensors are not affected. That is why the notebook&#039;s <code>torch.set_default_dtype(torch.int)<\/code> raises a <code>TypeError<\/code>: the default can only be a floating-point type.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The notebook sets the default to <code>float64<\/code> near the top and never sets it back, so every later float tensor in that session is double precision. <code>float64<\/code> doubles memory use and is much slower on most GPUs. Run <code>torch.set_default_dtype(torch.float32)<\/code> after the experiment, or pass <code>dtype=torch.float64<\/code> only where you need it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">In-place operations, views and shared memory<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Methods that end in an underscore (<code>add_<\/code>, <code>sqrt_<\/code>, <code>fill_<\/code>) modify the tensor they are called on. The version without the underscore returns a new tensor. Some in-place operations have no underscore: <code>x += 1<\/code>, index assignment such as <code>x[0] = 5<\/code>, and functions called with an <code>out=<\/code> argument. The notebook says <code>fill_<\/code> has no out-of-place equivalent. There is no <code>Tensor.fill<\/code> method, which is the <code>AttributeError<\/code> shown above, but <code>torch.full_like(x, 10)<\/code> does the same job out of place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>view()<\/code>, <code>transpose()<\/code>, slicing and <code>unsqueeze()<\/code> return views. A view shares memory with the original tensor, so changing one changes the other. That is why <code>resized_tensor<\/code> showed <code>100.<\/code> after <code>random_tensor[2, 2]<\/code> was changed. Use <code>clone()<\/code> when you need an independent copy.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">a = torch.tensor(&#91;&#91;<span class=\"hljs-number\">10.<\/span>, <span class=\"hljs-number\">8.<\/span>, <span class=\"hljs-number\">30.<\/span>], &#91;<span class=\"hljs-number\">40.<\/span>, <span class=\"hljs-number\">5.<\/span>, <span class=\"hljs-number\">6.<\/span>], &#91;<span class=\"hljs-number\">12.<\/span>, <span class=\"hljs-number\">2.<\/span>, <span class=\"hljs-number\">21.<\/span>]])\n\nflat = a.view(<span class=\"hljs-number\">9<\/span>)\n<span class=\"hljs-keyword\">print<\/span>(flat.data_ptr() == a.data_ptr())   <span class=\"hljs-comment\"># True: same storage<\/span>\n<span class=\"hljs-keyword\">print<\/span>(a.view(<span class=\"hljs-number\">-1<\/span>, <span class=\"hljs-number\">3<\/span>).shape)               <span class=\"hljs-comment\"># torch.Size(&#91;3, 3]); -1 is inferred<\/span>\n\nat = a.T                                 <span class=\"hljs-comment\"># transpose is a view, not contiguous<\/span>\n<span class=\"hljs-keyword\">print<\/span>(at.is_contiguous())                <span class=\"hljs-comment\"># False<\/span>\n<span class=\"hljs-comment\"># at.view(9)  -&gt; RuntimeError: view size is not compatible with input tensor's size and stride<\/span>\n<span class=\"hljs-keyword\">print<\/span>(at.reshape(<span class=\"hljs-number\">9<\/span>))                     <span class=\"hljs-comment\"># works; copies when it has to<\/span>\n<span class=\"hljs-keyword\">print<\/span>(at.contiguous().view(<span class=\"hljs-number\">9<\/span>))           <span class=\"hljs-comment\"># equivalent explicit form<\/span>\n\nsafe = a.<span class=\"hljs-keyword\">clone<\/span>()                         <span class=\"hljs-comment\"># independent copy<\/span>\nsafe&#91;<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">0<\/span>] = <span class=\"hljs-number\">-1<\/span>\n<span class=\"hljs-keyword\">print<\/span>(a&#91;<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">0<\/span>])                           <span class=\"hljs-comment\"># tensor(10.) - original unchanged<\/span>\n\n<span class=\"hljs-comment\"># torch.tensor() copies NumPy data; torch.from_numpy() shares it<\/span>\nimport numpy <span class=\"hljs-keyword\">as<\/span> np\nn = np.ones(<span class=\"hljs-number\">3<\/span>)\nshared = torch.from_numpy(n)\nn&#91;<span class=\"hljs-number\">0<\/span>] = <span class=\"hljs-number\">99<\/span>\n<span class=\"hljs-keyword\">print<\/span>(shared)                            <span class=\"hljs-comment\"># tensor(&#91;99., 1., 1.], dtype=torch.float64)<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> In-place operations can break autograd. Calling <code>w.add_(1)<\/code> on a leaf tensor created with <code>requires_grad=True<\/code> raises a RuntimeError. Wrap the update in <code>with torch.no_grad():<\/code>, which is what optimizers do internally.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Splitting, joining and sorting: what the arguments mean<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Function<\/th><th>Second argument means<\/th><th>Example from the lab<\/th><\/tr><\/thead><tbody><tr><td><code>torch.chunk(x, n, dim)<\/code><\/td><td>Number of chunks<\/td><td>15 elements, 3 chunks: three tensors of 5<\/td><\/tr><tr><td><code>torch.split(x, size, dim)<\/code><\/td><td>Size of each piece (or a list of sizes)<\/td><td>3 rows split by 2: a 2-row tensor and a 1-row tensor<\/td><\/tr><tr><td><code>torch.cat(seq, dim)<\/code><\/td><td>Existing dimension to join along<\/td><td>Shapes must match in every other dimension<\/td><\/tr><tr><td><code>torch.stack(seq, dim)<\/code><\/td><td>New dimension to create<\/td><td>All tensors must have exactly the same shape<\/td><\/tr><tr><td><code>torch.sort(x, dim=-1, descending=False)<\/code><\/td><td>Dimension to sort along<\/td><td>Returns <code>(values, indices)<\/code> and sorts each row by default<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When the size does not divide evenly, <code>chunk<\/code> may return fewer pieces than requested, while <code>split<\/code> always returns pieces of the requested size plus a smaller last piece. Use <code>split<\/code> when every piece must have a fixed size, for example mini-batches. To sort columns instead of rows, call <code>torch.sort(a, dim=0)<\/code>. For only the largest or smallest k values, <code>torch.topk<\/code> is faster than a full sort.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors in this lab and how to fix them<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>TypeError: only floating-point types are supported as the default type<\/code><\/td><td>Passing an integer dtype to <code>set_default_dtype<\/code><\/td><td>Pass <code>dtype=torch.int32<\/code> to the tensor instead<\/td><\/tr><tr><td><code>AttributeError: &#039;Tensor&#039; object has no attribute &#039;fill&#039;<\/code><\/td><td>No out-of-place <code>fill<\/code> method exists<\/td><td>Use <code>x.fill_(v)<\/code> or <code>torch.full_like(x, v)<\/code><\/td><\/tr><tr><td><code>RuntimeError: shape &#039;[-1, 6]&#039; is invalid for input of size 9<\/code><\/td><td>The new shape must have exactly the same number of elements; 9 is not divisible by 6<\/td><td>Use a compatible shape such as <code>view(-1, 3)<\/code> or <code>view(9)<\/code><\/td><\/tr><tr><td><code>view size is not compatible with input tensor&#039;s size and stride<\/code><\/td><td>Calling <code>view<\/code> on a non-contiguous tensor, such as a transpose<\/td><td>Use <code>reshape()<\/code> or call <code>.contiguous()<\/code> first<\/td><\/tr><tr><td><code>Sizes of tensors must match except in dimension 0<\/code><\/td><td>Mismatched shapes passed to <code>torch.cat<\/code><\/td><td>Check <code>.shape<\/code> of every input; reshape or pad first<\/td><\/tr><tr><td><code>expected scalar type Float but found Double<\/code><\/td><td>Mixing float64 data (often from NumPy or the default dtype) with float32 models<\/td><td>Convert with <code>.float()<\/code> or <code>.to(torch.float32)<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> In the notebook, <code>resized_tensor.size()<\/code> still returns <code>torch.Size([9])<\/code> after the failed <code>view(-1, 6)<\/code>. The assignment never happened, so the variable still holds the earlier flattened view. The new shape was not partly applied.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between torch.Tensor and torch.tensor?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>torch.tensor()<\/code> is a factory function that infers the dtype from the data, or takes an explicit <code>dtype<\/code>, and always copies the data. <code>torch.Tensor<\/code> is the class constructor. It always produces the default floating-point type, and with integer arguments it allocates uninitialised memory of that shape. Use <code>torch.tensor<\/code> for data and <code>torch.empty<\/code>, <code>torch.zeros<\/code> or <code>torch.ones<\/code> for a given shape.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between view() and reshape() in PyTorch?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>view()<\/code> always returns a tensor that shares memory with the original and fails if the tensor is not contiguous. <code>reshape()<\/code> returns a view when it can and makes a copy when it must, so it works on any tensor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I make an independent copy of a PyTorch tensor?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>x.clone()<\/code>. Add <code>.detach()<\/code> if the copy should not be tracked by autograd. Assignment (<code>y = x<\/code>), slicing and <code>view()<\/code> all share memory with the original.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does torch.full return an integer tensor?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Current PyTorch versions infer the dtype from <code>fill_value<\/code>, so <code>torch.full((2, 3), 10)<\/code> returns <code>int64<\/code>. Pass <code>10.0<\/code> or <code>dtype=torch.float32<\/code> to get a float tensor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">When should I avoid in-place operations?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Avoid them on tensors that autograd needs for the backward pass, especially leaf tensors with <code>requires_grad=True<\/code>. These raise errors or produce wrong gradients. They are safe for preprocessing data or inside a <code>torch.no_grad()<\/code> block.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/artificial-intelligence\/machine-learning\/\">More Machine Learning tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/staff-mlops-engineer-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Staff MLOps Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/lead-machine-learning-engineer-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Lead Machine Learning Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This lab covers the core PyTorch tensor operations: creating tensors, choosing data types, in-place and out-of-place operations, indexing and slicing, splitting and joining, views and reshaping, and&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[6512],"tags":[7364],"class_list":["post-47563","post","type-post","status-publish","format-standard","hentry","category-machine-learning","tag-pytorch"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=47563"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47563\/revisions"}],"predecessor-version":[{"id":80166,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/47563\/revisions\/80166"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=47563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=47563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=47563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}