<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Written lessons | Md. Mahbubur Rahman</title><link>https://mmrahman-academic-mmrwyo.pages.dev/lessons/</link><atom:link href="https://mmrahman-academic-mmrwyo.pages.dev/lessons/index.xml" rel="self" type="application/rss+xml"/><description>Written lessons</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>en-us</language><image><url>https://mmrahman-academic-mmrwyo.pages.dev/media/icon_hu_1c0e9cb08cfb822a.png</url><title>Written lessons</title><link>https://mmrahman-academic-mmrwyo.pages.dev/lessons/</link></image><item><title>Tensors and shapes</title><link>https://mmrahman-academic-mmrwyo.pages.dev/lessons/01-tensors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://mmrahman-academic-mmrwyo.pages.dev/lessons/01-tensors/</guid><description>&lt;p&gt;A tensor stores values in a multidimensional array. In image learning, dimensions often describe the batch, channels, height, and width.&lt;/p&gt;
&lt;p&gt;For a batch of eight RGB images resized to 224 by 224 pixels, the usual PyTorch shape is &lt;code&gt;(8, 3, 224, 224)&lt;/code&gt;. A single-channel depth input would normally have shape &lt;code&gt;(8, 1, 224, 224)&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;torch&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;rgb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;depth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;224&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;rgbd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cat&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;depth&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dim&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rgbd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# torch.Size([8, 4, 224, 224])&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Concatenation only aligns array dimensions. It does not register the cameras, convert depth units, or remove invalid depth values. Those steps must be handled before treating the channels as corresponding observations.&lt;/p&gt;
&lt;h2 id="try-it"&gt;Try it&lt;/h2&gt;
&lt;p&gt;Change the batch size, then inspect every tensor shape. Consider which preprocessing steps are shared between RGB and depth and which require separate handling.&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;</description></item><item><title>Training and evaluation</title><link>https://mmrahman-academic-mmrwyo.pages.dev/lessons/02-training/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://mmrahman-academic-mmrwyo.pages.dev/lessons/02-training/</guid><description>&lt;p&gt;Training adjusts model parameters using examples and a loss function. Validation informs choices such as hyperparameters and stopping time. The test set evaluates the final procedure after those choices are fixed.&lt;/p&gt;
&lt;h2 id="a-reliable-sequence"&gt;A reliable sequence&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Define the prediction target and the unit of independence.&lt;/li&gt;
&lt;li&gt;Split the data before fitting preprocessing or selecting a model.&lt;/li&gt;
&lt;li&gt;Fit using training data and choose settings using validation data.&lt;/li&gt;
&lt;li&gt;Evaluate the frozen procedure on the held-out test data.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For repeated observations of plants, an image-level random split can place the same plant in both training and test sets. A plant-level split is more appropriate when the goal is performance on unseen plants.&lt;/p&gt;
&lt;h2 id="evaluation-mode"&gt;Evaluation mode&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inference_mode&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;predictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Evaluation mode changes the behavior of layers such as dropout and batch normalization. Disabling gradient recording reduces the work required during inference. These operations serve different purposes.&lt;/p&gt;
&lt;h2 id="try-it"&gt;Try it&lt;/h2&gt;
&lt;p&gt;Write down the grouping variable for your own dataset. Check whether any group appears in more than one partition.&lt;/p&gt;</description></item><item><title>Working with RGB-D observations</title><link>https://mmrahman-academic-mmrwyo.pages.dev/lessons/03-rgbd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://mmrahman-academic-mmrwyo.pages.dev/lessons/03-rgbd/</guid><description>&lt;p&gt;RGB describes appearance. Depth describes distance according to the sensor&amp;rsquo;s coordinate system and unit convention. Combining them requires attention to calibration, alignment, missing measurements, and scale.&lt;/p&gt;
&lt;h2 id="before-modeling"&gt;Before modeling&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Record the sensor, depth units, and calibration used for each collection.&lt;/li&gt;
&lt;li&gt;Verify alignment between the color image, depth image, and any segmentation masks.&lt;/li&gt;
&lt;li&gt;Keep track of invalid depth values instead of treating them as valid zero-distance observations.&lt;/li&gt;
&lt;li&gt;Apply spatial transformations consistently across corresponding channels and masks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="evaluating-a-benefit-from-depth"&gt;Evaluating a benefit from depth&lt;/h2&gt;
&lt;p&gt;Compare RGB and RGB-D models using the same data partitions and training budget. Check results by occlusion severity or other relevant conditions. An improvement in aggregate performance alone does not explain when depth contributes.&lt;/p&gt;
&lt;h2 id="try-it"&gt;Try it&lt;/h2&gt;
&lt;p&gt;Inspect a color image, a depth image, and a validity mask side by side. Look for boundary misalignment and regions where the sensor did not return a usable measurement.&lt;/p&gt;</description></item></channel></rss>