<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Coding Malik on Medium]]></title>
        <description><![CDATA[Stories by Coding Malik on Medium]]></description>
        <link>https://medium.com/@codingmalik?source=rss-f796f813fb79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NyP1QZOHeChtovCZMTAtdg.jpeg</url>
            <title>Stories by Coding Malik on Medium</title>
            <link>https://medium.com/@codingmalik?source=rss-f796f813fb79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:24:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codingmalik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[C Program to Load and Resize Images into Tensor]]></title>
            <link>https://medium.com/@codingmalik/c-program-to-load-and-resize-images-into-tensor-cbdb26176623?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbdb26176623</guid>
            <category><![CDATA[nearest-neighbor-c]]></category>
            <category><![CDATA[stb-image-c]]></category>
            <category><![CDATA[c-image-processing]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 21:19:13 GMT</pubDate>
            <atom:updated>2025-09-07T21:19:13.065Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*spu7sQZs453QZR3a2x8GZg.png" /></figure><p>Learn how to load, resize, and convert images into tensor format using C and stb_image. Full code, step-by-step explanation, and demo included.</p><h3>Script:</h3><p>Bro, in this guide we’ll break down a complete C program that loads images from a folder, resizes them with nearest-neighbor interpolation, and converts them into a tensor (NCHW format). We’ll explain each part of the code step by step in simple language, so even if you’re new to C, you’ll get the full picture without confusion.</p><h4><a href="https://aitoolskit.pro/notebook/">Download Complete Notebook</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbdb26176623" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own AI Coding Agent Using Python Flask and Hugging Face]]></title>
            <link>https://medium.com/@codingmalik/build-your-own-ai-coding-agent-using-python-flask-and-hugging-face-411cc2b4274d?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/411cc2b4274d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 15:27:55 GMT</pubDate>
            <atom:updated>2025-08-28T15:27:55.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*gXfGRtSp0e8OB_PGkvyR0g.png" /></figure><p>Want to create your own AI coding agent that can build apps, fix bugs, and even explain code step by step? In this video, I’ll show you how to set up a Flask app powered by Hugging Face’s Qwen2 multimodal model. We’ll cover: Setting up Flask backend for AI inference Using Qwen2VL for real-time coding assistance Generating &amp; explaining code in any programming language Building an interactive frontend + API to handle AI jobs Optimizing for CPU &amp; GPU inference This project is 100% free, and you can run it on your own machine. Perfect if you want to explore AI + programming automation or build your personal coding Copilot from scratch!</p><h4>Script:</h4><p>Imagine having your own AI coding agent, built completely from scratch, running right on your computer. In this video, I’m going to show you how to create a powerful coding assistant using Python, Flask, and Hugging Face models. This AI won’t just write code, it will also explain every step it takes, making programming smarter and easier. We’ll set up a real-time system that can generate, fix, and even optimize code in any language. The best part? It’s free, and you don’t need expensive hardware to get started. I’ll walk you through the backend with Flask, connect it to Hugging Face’s Qwen2 model, and show you how to handle inference like a pro. By the end, you’ll have a fully working AI agent that feels like your personal coding copilot. So get ready, because this project might just change the way you code forever.</p><h3>Code:</h3><pre># this is app.py code for complete notebook click on below download button<br>from flask import Flask, render_template, jsonify, request<br>from core.util import * # means import everything<br>import uuid, os, shutil, gc<br>from transformers import Qwen2VLForConditionalGeneration, AutoProcessor<br>from threading import Thread, Lock<br>import torch<br>lock = Lock()<br>job = {}<br>app = Flask(__name__)<br>device = torch.device(&quot;cuda&quot; if torch.cuda.is_available() else &quot;cpu&quot;)<br>dtype = torch.float16 if torch.cuda.is_available() else torch.float32 # for gpu &amp; cpu<br>model = None<br>processor = None<br><br># im using my cpu<br># now you need to understand that this model is highly optimized which<br># can understand text, image, video as an input<br># for making eveything smart, cool im working with text only<br># in out case it is coding agent which generate code with expaination<br><br># route for home page<br>@app.route(&quot;/&quot;)<br>def home():<br>    return render_template(&quot;index.html&quot;)<br><br># clean_caches<br>def clean_caches():<br>    try:<br>        path = os.path.expanduser(&quot;~/.cache/huggingface&quot;)<br>        if os.path.exist(path):<br>            shutil.rmtree(path)<br>            print(&quot;Caches cleared&quot;)<br>    except Exception as e:<br>        print(&quot;No caches Found&quot;)<br><br># function to generate code &amp; exp<br>def generate_code_using_ai(job_id, prompt):<br>    global device, dtype, model, processor<br>    try:<br>        # im loading model from my directory<br>        # if you load model from remote server using huggingface<br>        # pass this function clean_caches after tokenization to release memory<br>        if model == None and processor == None:<br>            token = get_hug_token()<br>            path = os.path.join(&quot;vl-model-instruct&quot;)<br>            model = Qwen2VLForConditionalGeneration.from_pretrained(<br>                path,<br>                torch_dtype=dtype,<br>                device_map=device,<br>                low_cpu_mem_usage=True,<br>                token=token<br>            ).to(device) # compulsary most important<br>            processor = AutoProcessor.from_pretrained(path, token=token)<br>            model.eval() # because we are doing inference<br>        <br><br>        print(f&quot;Prompt: {prompt}&quot;)<br>        pre_pros = create_prompt_for_model(prompt)<br>        chat = processor.apply_chat_template(pre_pros, tokenize=False, add_generation_prompt=True)<br><br>        # now tokenize it for text<br>        inputs = processor(<br>            text=[chat],<br>            return_tensors=&quot;pt&quot;,<br>            truncation=True,<br>            padding=True<br>        ).to(device) # most important<br><br>        # in my case it wont effect on anything but<br>        # when loading remotely it is powerful<br>        clean_caches()<br><br>        # now we need to use torch.no_grad because we are not training<br>        # you can use batch_decode function if you need to use streaming outputs<br>        with torch.no_grad():<br>            output = model.generate(<br>                **inputs,<br>                max_new_tokens=2048, # i have multiple threads in my cpu so 1024 is fast and perfect for this usecase but this is on you<br>                pad_token_id=processor.tokenizer.eos_token_id,<br>                top_p=0.95,<br>                repetition_penalty=1.05<br>            )<br><br>        # get the final output<br>        output = output[:, inputs[&#39;input_ids&#39;].shape[1]:] # sorry this will be the last mistake<br>        decode = processor.decode(output[0], skip_special_tokens=True, clean_up_tokenization_spaces=True)<br>        print(f&quot;Response: {decode}&quot;)<br>        # done<br>        # return whatever we get from model<br>        with lock:<br>            job[job_id] = {&quot;status&quot;: &quot;done&quot;, &quot;msg&quot;: clean_for_code(decode)}<br>            model = None<br>            processor = None<br><br>    except Exception as e:<br>        print(str(e))<br>        with lock:<br>            job[job_id] = {&quot;status&quot;: &quot;error&quot;, &quot;msg&quot;: &quot;job not found&quot;}<br>            model = None<br>            processor = None<br>    finally:<br>        # default python garbage collector<br>        gc.collect()<br><br># route for generating code<br>@app.route(&quot;/generate-code&quot;, methods=[&#39;POST&#39;])<br>def generate_code():<br>    data = request.get_json()<br>    prompt = data.get(&quot;prompt&quot;, &quot;&quot;)<br>    clean_prompt = preprocess_input_for_code(prompt)<br><br>    # now we will use threads to start the job &amp; handle eveything efficiently<br>    # when you use lock it will handle multiple request efficiently<br>    # at once it will process single req and put the rest into the queue<br><br>    with lock:<br>        job_id = str(uuid.uuid4())<br>        job[job_id] = {&quot;status&quot;: &quot;pending&quot;, &quot;msg&quot;: &quot;job is pending&quot;}<br><br>    # start the background processing<br>    Thread(target=generate_code_using_ai, args=(job_id, clean_prompt)).start()<br>    return jsonify({&quot;status&quot;:&quot;success&quot;, &quot;job_id&quot;: job_id})<br><br># last route to send the progress<br>@app.route(&quot;/check-job/&lt;job_id&gt;&quot;, methods=[&#39;GET&#39;])<br>def check_job(job_id):<br>    with lock:<br>        print(job_id)<br>        if job_id in job:<br>            return jsonify(job[job_id])<br>        return jsonify({&quot;status&quot;: &quot;error&quot;, &quot;msg&quot;: &quot;No job found&quot;})<br><br># now we are done<br>if __name__ == &quot;__main__&quot;:<br>    app.run(debug=True, port=&#39;5000&#39;)</pre><h3>Download Notebook</h3><p>https://aitoolskit.pro/notebook</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=411cc2b4274d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Orthogonal Initialization in Neural Networks Explained with PyTorch]]></title>
            <link>https://medium.com/@codingmalik/orthogonal-initialization-in-neural-networks-explained-with-pytorch-e855ee0cbdff?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/e855ee0cbdff</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[orthogonal-initialization]]></category>
            <category><![CDATA[numpy]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 14:14:01 GMT</pubDate>
            <atom:updated>2025-08-22T14:14:01.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*ljAZ9eiv815MCM7-1sNSfg.png" /></figure><p>Boost your neural network performance with Orthogonal Initialization! 🚀 In this short and clear tutorial, we’ll explore how orthogonal matrices improve training stability, speed up convergence, and prevent vanishing or exploding gradients. You’ll learn:</p><p>✅ What Orthogonal Initialization is in deep learning</p><p>✅ Why it’s important for efficient training</p><p>✅ How to implement it in PyTorch &amp; NumPy</p><p>✅ Real benefits in AI model optimization</p><h3>Script:</h3><p>Orthogonal weights keep directions independent and preserve vector lengths, preventing distortion. This stabilizes signal flow across layers and reduces exploding or vanishing gradients. Because the transform is well-conditioned, optimization converges faster and more reliably. In RNNs and deep MLPs, orthogonal init helps retain information over long depths or time. Convolutional kernels benefit too, encouraging diverse, non-redundant features. Numerically, the inverse is just a transpose — cheap and stable for repeated ops. Overall, you get cleaner gradients, better generalization, and smoother training. Try it with nn.init.orthogonal_ in PyTorch for an immediate boost.</p><h3>Code:</h3><pre>import torch, numpy as np<br>import torch.nn as nn<br>import torch.nn.functional as F<br><br># --- Intro: tiny MLP with orthogonal weights ---<br>class OrthogonalNet(nn.Module):<br>    def __init__(self, d_in=16, d_h=32, d_out=4):<br>        super().__init__()<br>        self.fc1 = nn.Linear(d_in, d_h, bias=True)<br>        self.fc2 = nn.Linear(d_h, d_out, bias=True)<br>        for layer in (self.fc1, self.fc2):<br>            nn.init.orthogonal_(layer.weight)      # key line<br>            nn.init.zeros_(layer.bias)<br><br>    def forward(self, x):<br>        x = F.relu(self.fc1(x))                    # nonlinearity after orthogonal map<br>        return self.fc2(x)<br><br>model = OrthogonalNet()<br>x = torch.randn(8, 16)<br>y_true = torch.randint(0, 4, (8,))<br><br># Orthogonality check (W W^T ≈ I)<br>W = model.fc1.weight.detach().numpy()<br>print(&quot;Orthogonality check (fc1):\n&quot;, np.round(W @ W.T, 3))<br><br># One training step (shows stability of grads)<br>opt = torch.optim.Adam(model.parameters(), lr=1e-3)<br>logits = model(x)<br>loss = F.cross_entropy(logits, y_true)<br>opt.zero_grad(); loss.backward(); opt.step()<br>print(&quot;Loss:&quot;, float(loss))</pre><h4><a href="https://aitoolskit.pro/notebook">Download Notebook</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e855ee0cbdff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rust Explained Simply Transpose Jagged Matrix]]></title>
            <link>https://medium.com/@codingmalik/rust-explained-simply-transpose-jagged-matrix-e2a8dd44333b?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2a8dd44333b</guid>
            <category><![CDATA[rust-programming]]></category>
            <category><![CDATA[rust-vector]]></category>
            <category><![CDATA[rust-matrix-transpose]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 01:16:49 GMT</pubDate>
            <atom:updated>2025-08-21T01:16:49.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*-Xzw9en_FYWLUqmOjsVRCA.png" /></figure><p>Learn Rust programming in the simplest way! 🦀 In this short video, we explain how to transpose a jagged (unequal row length) matrix in Rust step by step. Perfect for beginners who want to understand Rust basics like vectors, iterators, collect, and matrix operations.</p><h3>Script:</h3><p>Hey friends! Today we’re going to learn about a cool Rust function that transposes a matrix, even when its rows are uneven in length. Normally, transposing means flipping rows into columns, but with jagged arrays, some rows may not have enough elements. That’s where this function helps us handle the missing pieces easily. First, it looks at all the rows and finds the longest one, so it knows how many columns are needed. Then, it loops column by column instead of row by row. For each column, it checks every row to see if an element exists at that spot. If the element is there, it takes it, but if it’s missing, it safely puts a zero in its place. After collecting all those elements, it forms the new rows of the transposed matrix. This way, every column becomes a row, even when the original matrix had uneven shapes. The unwrap_or(0) is the trick that prevents errors and fills gaps with zeros. Finally, the code puts everything together and gives us the new, neat transposed matrix.</p><h4><a href="https://aitoolskit.pro/notebook">Notebook Download</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2a8dd44333b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1D to 5D Tensors Explained Deep learning made easy]]></title>
            <link>https://medium.com/@codingmalik/1d-to-5d-tensors-explained-deep-learning-made-easy-1b05302343ea?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b05302343ea</guid>
            <category><![CDATA[1d-tensor]]></category>
            <category><![CDATA[2d-tensor]]></category>
            <category><![CDATA[4d-tensor]]></category>
            <category><![CDATA[3d-tensor]]></category>
            <category><![CDATA[tensors-explained]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 17:50:19 GMT</pubDate>
            <atom:updated>2025-08-19T17:50:19.943Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*ALsRz8omNLVAhFKDeqFiaQ.png" /></figure><p>Unlock the secrets of tensors in deep learning! 🚀 In this short, we break down 1D, 2D, 3D, 4D, and 5D tensors with simple examples and visuals. Learn how data is organized from vectors to batches, attention heads, and Mixture of Experts (MoE). Perfect for AI enthusiasts, students, and developers looking to understand how neural networks process multi-dimensional data. 💡 What you’ll learn: How 1D to 5D tensors are structured Real examples with matrices and cubes How tensors map data in AI models Visualizing shapes to understand deep learning data flow</p><h3>Script:</h3><p>This code demonstrates how data can be represented in tensors from 1D to 5D. Tensors are multi-dimensional arrays used to organize and process data in deep learning models. Starting from simple 1D vectors, we progress to complex 5D tensors used in advanced architectures. Each dimension adds structure, enabling models to handle sequences, batches, features, and expert outputs efficiently. 1D tensors are single-dimensional sequences, useful for simple numeric data or embeddings. 2D tensors form matrices, representing tabular data, images, or word embeddings. 3D tensors handle batches of sequences or images, adding depth to data representation. 4D tensors are essential in attention mechanisms, capturing batch, heads, sequence length, and features. 5D tensors allow models like Mixture of Experts to include multiple expert outputs per token. Printing shapes and example values clarifies how each tensor dimension organizes data and maps to the original input.</p><h3>Code:</h3><pre>import torch<br><br># =======================================<br># 1D Tensor Example<br># =======================================<br># A simple 1D tensor (vector) with example values<br>tensor_1d = torch.tensor([10, 20, 30, 40, 50])<br>print(&quot;\n1D Tensor (Vector):&quot;)<br>print(tensor_1d)<br><br># =======================================<br># 2D Tensor Example<br># =======================================<br># Shape: (rows, columns) = (3,4) with example values<br>tensor_2d = torch.tensor([[1,2,3,4],[5,6,7,8],[9,10,11,12]])<br>print(&quot;\n2D Tensor (Matrix):&quot;)<br>print(tensor_2d)<br><br># =======================================<br># 3D Tensor Example<br># =======================================<br># Shape: (depth, rows, columns) = (2,3,4) with example values<br>tensor_3d = torch.tensor([<br>    [[1,2,3,4],[5,6,7,8],[9,10,11,12]],<br>    [[13,14,15,16],[17,18,19,20],[21,22,23,24]]<br>])<br>print(&quot;\n3D Tensor (Cube / Batch of Matrices):&quot;)<br>print(tensor_3d)<br><br># =======================================<br># 4D Tensor Example<br># =======================================<br># Shape: (batch, heads, seq_len, features_per_head) = (1, 2, 3, 4) with example values<br>tensor_4d = torch.tensor([[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],<br>                            [[13,14,15,16],[17,18,19,20],[21,22,23,24]]]])<br>print(&quot;\n4D Tensor (Batch x Heads x Tokens x Features):&quot;)<br>print(tensor_4d)<br><br># =======================================<br># 5D Tensor Example<br># =======================================<br># Shape: (batch, heads, seq_len, features_per_head, experts) = (1,2,3,4,2) with example values<br>tensor_5d = torch.tensor([[[[[1,101],[2,102],[3,103],[4,104]],<br>                             [[5,105],[6,106],[7,107],[8,108]],<br>                             [[9,109],[10,110],[11,111],[12,112]]],<br>                            [[[13,113],[14,114],[15,115],[16,116]],<br>                             [[17,117],[18,118],[19,119],[20,120]],<br>                             [[21,121],[22,122],[23,123],[24,124]]]]])<br>print(&quot;\n5D Tensor (Batch x Heads x Tokens x Features x Experts):&quot;)<br>print(tensor_5d)<br><br># =======================================<br># Quick visualization: print shapes<br># =======================================<br>print(&quot;\nShapes of tensors:&quot;)<br>print(&quot;1D:&quot;, tensor_1d.shape)<br>print(&quot;2D:&quot;, tensor_2d.shape)<br>print(&quot;3D:&quot;, tensor_3d.shape)<br>print(&quot;4D:&quot;, tensor_4d.shape)<br>print(&quot;5D:&quot;, tensor_5d.shape)</pre><h4><a href="https://aitoolskit.pro/notebook">Download Notebook</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b05302343ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear vs Convolution vs Attention Deep Learning Explained]]></title>
            <link>https://medium.com/@codingmalik/linear-vs-convolution-vs-attention-deep-learning-explained-6abb6c4f0f8f?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/6abb6c4f0f8f</guid>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[deep-learning-explained]]></category>
            <category><![CDATA[linear]]></category>
            <category><![CDATA[convolution]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 17:32:32 GMT</pubDate>
            <atom:updated>2025-08-19T17:32:32.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*oEvXoKb0nG2Bqb46ashMAw.png" /></figure><p>Unlock the secrets of Deep Learning in just 60 seconds! 💡 Discover the difference between Linear, Convolution, and Attention layers with simple examples. These concepts power today’s smartest AI models — and now you can master them too!</p><h3>Script:</h3><p>Deep learning is a journey of turning simple numbers into intelligence. A Linear layer transforms data into a new space, giving it fresh meaning. A Convolutional layer captures hidden patterns, perfect for images and sequences. An Attention layer looks globally, connecting every piece of data with context. Together, these layers form the foundation of today’s smartest AI models. Each plays a unique role in how machines understand the world. Mastering them opens the door to endless innovation in AI. Subscribe now and get the complete Jupyter notebook on our site to start building smarter models today.</p><h3>Code:</h3><pre>import torch<br>import torch.nn as nn<br>import torch.nn.functional as F<br><br># Dummy input (sequence of length=5, features=4)<br>x = torch.randn(1, 5, 4)  # [batch=1, seq_len=5, features=4]<br><br>print(&quot;Input shape:&quot;, x.shape)<br><br># ====================<br># 1. Linear Layer<br># ====================<br>linear = nn.Linear(4, 3)   # project 4-dim -&gt; 3-dim<br>out_linear = linear(x)<br><br>print(&quot;\nLinear Output Shape:&quot;, out_linear.shape)<br># COMMENT: Linear har token ke 4 features ko ek nayi 3D space me map karta hai<br># Har token independent transform hota hai (no sequence mixing).<br><br># ====================<br># 2. Conv1D Layer<br># ====================<br>conv1d = nn.Conv1d(in_channels=4, out_channels=3, kernel_size=2, stride=1)<br><br># Conv1d ko [batch, channels, seq_len] chahiye<br>x_conv = x.transpose(1, 2)  # [1, 4, 5]<br>out_conv = conv1d(x_conv)<br><br>print(&quot;\nConv1D Output Shape:&quot;, out_conv.shape)<br># COMMENT: Conv local sliding window se pattern pakadta hai<br># Yahan kernel_size=2 =&gt; har 2 consecutive tokens ka relation seekh raha hai.<br><br># ====================<br># 3. Self-Attention<br># ====================<br>d_model = 4<br>attn = nn.MultiheadAttention(embed_dim=d_model, num_heads=2, batch_first=True)<br>out_attn, _ = attn(x, x, x)  # Q=K=V=x<br>print(&quot;\nAttention Output Shape:&quot;, out_attn.shape)</pre><p><a href="https://aitoolskit.pro/notebook">Download Notebook</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6abb6c4f0f8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Encoder Decoder Model Text to Video with PyTorch]]></title>
            <link>https://medium.com/@codingmalik/simple-encoder-decoder-model-text-to-video-with-pytorch-a452ff77495d?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/a452ff77495d</guid>
            <category><![CDATA[vision-based-model]]></category>
            <category><![CDATA[encoder-decoder-model]]></category>
            <category><![CDATA[text-to-video]]></category>
            <category><![CDATA[pytorch]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 17:10:17 GMT</pubDate>
            <atom:updated>2025-08-28T14:19:58.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*szUELXeZRiIVaunI8JRqoA.png" /></figure><p>In this notebook, we explain how text sequences are encoded with an LSTM, transformed into latent embeddings, and decoded into video frames using 3D transpose convolutions. We also print out all the tensor shapes at each step, making it super easy to follow along. 👉 What you’ll learn in this Notebook: How an encoder-decoder architecture works in PyTorch Shape transformations from text embeddings to video tensors Using LSTM to process text input Generating video frames with 3D ConvTranspose layers Understanding latent space and final video output format</p><h3>Script:</h3><p>Welcome to this tutorial on building a simple text-to-video generator using PyTorch. We begin by encoding the text input with an LSTM network, where the text data is represented as a sequence of word embeddings in the shape of batch, sequence, and embedding dimensions. The LSTM processes this sequence step by step and produces a hidden representation of the text. From this hidden state, we use a fully connected layer to project it into a compact latent video embedding. This latent embedding is then reshaped into a three-dimensional tensor suitable for video generation. Next, the decoder comes into action, built with three-dimensional transpose convolutions. Each transpose convolution gradually upsamples the latent tensor, expanding it into frames that resemble a video. Finally, a sigmoid activation is applied to normalize the pixel values between zero and one, ensuring smooth and valid output frames. The result of this process has the clear shape of batch, channels, frames, height, and width. Once the output is generated, we compare the predicted video frames with the real video data to compute the training loss. Step by step, this allows the model to learn how to translate text sequences into dynamic video frames. And that is the core process of connecting natural language input to generated visual output in PyTorch.</p><h3>Code:</h3><pre>import torch<br>import torch.nn as nn<br><br>class TextToVideo(nn.Module):<br>    def __init__(self, text_dim=50, hidden_dim=128, frame_channels=3):<br>        super(TextToVideo, self).__init__()<br>        <br>        # Text encoder (LSTM)<br>        self.encoder = nn.LSTM(input_size=text_dim, hidden_size=hidden_dim, batch_first=True)<br>        <br>        # Latent → frame embedding<br>        self.fc = nn.Linear(hidden_dim, 256)<br>        <br>        # Decoder: Generate video frames (3D ConvTranspose)<br>        self.decoder = nn.Sequential(<br>            nn.ConvTranspose3d(16, 32, kernel_size=4, stride=2, padding=1), # [B,16,1,4,4] → [B,32,2,8,8]<br>            nn.ReLU(),<br>            nn.ConvTranspose3d(32, 16, kernel_size=4, stride=2, padding=1), # [B,32,2,8,8] → [B,16,4,16,16]<br>            nn.ReLU(),<br>            nn.ConvTranspose3d(16, frame_channels, kernel_size=4, stride=2, padding=1), # [B,16,4,16,16] → [B,3,8,32,32]<br>            nn.Sigmoid()  # normalize to [0,1]<br>        )<br>    <br>    def forward(self, text_input):<br>        # text_input: [batch, seq_len, text_dim]<br>        _, (h, _) = self.encoder(text_input)  # take hidden state<br>        h = self.fc(h[-1])                   # [batch, 256]<br>        <br>        # reshape to video latent [batch, C, D, H, W]<br>        x = h.view(-1, 16, 1, 4, 4)          # 16 channels, depth=1, H=W=4<br>        video_out = self.decoder(x)          # → [batch, 3, frames, H, W]<br>        return video_out<br><br><br># ---------------- Dummy Data ----------------<br># Suppose batch_size = 2, seq_len = 10 words, vocab_dim = 50 (embedding size)<br>text_data = torch.randn(2, 10, 50)   # [batch, seq_len, embedding_dim]<br><br># Suppose each video has 16 frames, each frame is 3x64x64<br>video_data = torch.randn(2, 16, 3, 64, 64)  # [batch, frames, channels, H, W]<br><br># ---------------- Run Model ----------------<br>model = TextToVideo()<br>video_out = model(text_data)<br><br>print(&quot;Text input shape:&quot;, text_data.shape)<br>print(&quot;Video target shape:&quot;, video_data.shape)<br>print(&quot;Video output shape:&quot;, video_out.shape)<br><br>#output shapes<br>Text input shape: torch.Size([2, 10, 50])<br>Video target shape: torch.Size([2, 16, 3, 64, 64])<br>Video output shape: torch.Size([2, 3, 8, 32, 32])</pre><h3><strong>Download Source Code</strong></h3><p>sorry this is the new link to get all the notebooks</p><p>https://aitoolskit.pro/notebook</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a452ff77495d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradient HeroWith Text in CSS]]></title>
            <link>https://medium.com/@codingmalik/gradient-herowith-text-in-css-acb455df7e51?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/acb455df7e51</guid>
            <category><![CDATA[grandient-effects]]></category>
            <category><![CDATA[html-css-project]]></category>
            <category><![CDATA[hero-with-text]]></category>
            <category><![CDATA[css-properties]]></category>
            <category><![CDATA[gradient-hero-effect]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 15:30:28 GMT</pubDate>
            <atom:updated>2024-03-06T15:30:28.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMbfmTbVNFqOQLXksl4WSQ.png" /></figure><h3>About Gradient Hero With Text Effect in CSS</h3><p>Welcome to our latest blog post! This article will cover how to create a gradient effect on both the hero section and text, using the mark tag along with other unique CSS properties that most developers may not know about. We will provide a comprehensive overview of creating a hero section with background and text effects. I will try to explain everything in detail so that you can follow along easily.</p><h3>Custom HTML Layout</h3><p>To start the project, we need to create two files: index.html and style.css. In the HTML file, we structure the page by using a main div, row, col, and other necessary elements. For my project, I used three div elements, an h2 tag, an h4 tag, and a tag for a button.</p><h3>CSS Editing</h3><p>When writing CSS, it’s crucial to have a solid grasp of the properties being used. Not everyone may be familiar with their primary purposes, so I recommend diving into the full article for a comprehensive understanding.</p><p>Let’s break down the process step by step:</p><p>Container Setup:</p><ul><li>We begin by setting up the main container. Inside this container, we’ll center the other content.</li><li>Additionally, we apply a sleek black background gradient effect to the entire body.</li></ul><ol><li>Row Class Editing:</li></ol><ul><li>Next, we focus on the row class. Here’s what we do:</li><li>Set the max-width to <strong>1200px</strong>. This ensures that the content doesn’t stretch too wide on larger screens.</li><li>Apply margin: auto to clear any default margin settings. This centers the row horizontally.</li><li>Add a padding of <strong>12px</strong> to accommodate the content across various devices.</li></ul><ol><li>Text and Link Styling:</li></ol><ul><li>Now, let’s enhance the text and anchor (&lt;a&gt;) tags:</li><li>Use the &lt;mark&gt; tag to create a beautiful gradient text effect. This highlights specific portions of the text in an eye-catching way.</li><li>We utilized CSS properties such as background-clip: text, -webkit-text-fill-color: transparent and background: linear-gradient to create gradient text effects within the text section.</li></ul><p>Understanding CSS properties thoroughly empowers you to create visually appealing and responsive designs. Happy coding! 🎨✨</p><h3>Custom Redirection on a tag</h3><p>In the final section, we will edit the tag using a gradient effect similar to linear gradient and specify the redirect destination for the user.</p><h3>Conclusion</h3><p>Finally, our hero section with a gradient effect is complete. I aimed to simplify the project to help you understand the CSS properties used.</p><h3>YouTube Video Tutorial</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FezizY7bmGoA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DezizY7bmGoA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FezizY7bmGoA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/392f093c2c65f88fc081c345c225aea0/href">https://medium.com/media/392f093c2c65f88fc081c345c225aea0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acb455df7e51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Artificial Intelligence Responsive Template Website Design]]></title>
            <link>https://medium.com/@codingmalik/artificial-intelligence-responsive-template-website-design-1db005197317?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/1db005197317</guid>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[website-templates]]></category>
            <category><![CDATA[ui-templates]]></category>
            <category><![CDATA[html-css-project]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Sat, 02 Mar 2024 11:07:06 GMT</pubDate>
            <atom:updated>2024-03-02T11:07:06.401Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZLp0M4u50qnlVCD35ie8Q.png" /></figure><h3>Introduction</h3><p>Welcome to MalikCodex! We are a platform dedicated to sharing knowledge and resources for developers like you. Whether you are a beginner or an experienced programmer, MalikCodex supports your learning journey and provides you with a wide range of valuable resources.</p><h3>Meet Owner</h3><p>Hi, I’m Malik Faizan, the founder of MalikCodex. As a passionate developer with years of experience, I have worked with a multitude of programming languages and technologies</p><h3>About Responsive Template For Artificial Intelligence Company Website</h3><p>Let&#39;s discuss how to create an amazing, high-quality artificial intelligence website for your company, complete with fantastic features and layout.</p><p>Let&#39;s take a look at this template and see what it has to offer. It&#39;s an ideal choice for those who are searching for a complete layout, complete with various features and animations. We have made every effort to build this template from scratch without the use of any external libraries. Everything is fully customizable and easy to navigate, making it a great choice for anyone looking for an easy-to-use template.</p><p>We used custom HTML, CSS, and Vanilla JavaScript, but used the fontawesome library for icons instead of writing them all from scratch.</p><h3>File Structure</h3><p>When you download the complete template from our website, make sure to read the license.txt file properly. The file structure includes all the HTML files along with an assets folder. Inside the assets folder, there are CSS, images, and javascript folders that contain relevant files.</p><h3>Responsive Layout</h3><p>This template is responsive on all mobile and tablet devices, with a simple and convenient dropdown navigation feature.</p><h3>Features and Animations</h3><p>&quot;When you open the template on your local host, you will see a lot of professional video animations that play as you scroll through the page. Each section has awesome skew edges, making everything look superb and easy to edit.&quot;</p><h3>Test the Demo on Vercel App</h3><blockquote>See the <a href="https://web-design-ai.vercel.app/">Demo</a></blockquote><h3>Conclusion</h3><p>For those who want a complete, professional, and fully editable website template with an awesome UI for a great user experience, this is the best option available.</p><h3>YouTube Video Tutorial</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTAsa9Kfzrag%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTAsa9Kfzrag&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTAsa9Kfzrag%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/04cab3da576825c6550c4fef62117969/href">https://medium.com/media/04cab3da576825c6550c4fef62117969/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1db005197317" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let's Create a Custom Sign-Up Model in HTML CSS & JavaScript With a Login Message On Success]]></title>
            <link>https://medium.com/@codingmalik/lets-create-a-custom-sign-up-model-in-html-css-javascript-with-a-login-message-on-success-29db8fd21897?source=rss-f796f813fb79------2</link>
            <guid isPermaLink="false">https://medium.com/p/29db8fd21897</guid>
            <category><![CDATA[html-css-javascript]]></category>
            <category><![CDATA[sign-up-custom-model]]></category>
            <category><![CDATA[css-model-popup]]></category>
            <category><![CDATA[sign-up-form-validation]]></category>
            <category><![CDATA[model-popup-effect]]></category>
            <dc:creator><![CDATA[Coding Malik]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 12:49:26 GMT</pubDate>
            <atom:updated>2024-02-02T12:49:26.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Custom signup model popup in javascript" src="https://cdn-images-1.medium.com/max/1024/1*IaSzPcwNZzOmwquu1Xl-Kg.png" /></figure><h3>Introduction</h3><p>Welcome to MalikCodex! We are a platform dedicated to sharing knowledge and resources for developers like you. Whether you are a beginner or an experienced programmer, MalikCodex supports your learning journey and provides you with valuable resources.</p><h3>Meet Owner</h3><p>Hi, I’m Malik Faizan, the founder of MalikCodex. As a passionate developer with years of experience, I have worked with a multitude of programming languages and technologies</p><h3>About Custom Sign-Up Model Popup in HTML CSS &amp; JavaScript</h3><p>In this blog post, We Will Discuss A Custom Sign-up Model Popup We Create With HTML CSS, and JavaScript. With Message Integration on Sign-up. In This Way, We will create our custom sign-up popup. We will dive deep into this post to understand the flowchart behind this Project. Move To the Next Block where I discuss The Structure We Build.</p><h3>Complete Structure For Custom Sign-up Model Popup</h3><p>This Project is straightforward. I try to teach the best and simplest. This project has 3 files <em>(index.html, style.css, script.js). </em>First Let&#39;s discuss About HTML Layout we Create. We will first create a div element in which the First section is for the button through which the user can select the model Popup. The other section is for models that will pop up when someone clicks on the first section button. In the model, there are two inputs and a single button.</p><p>These two inputs include an <strong>email</strong> field, a <strong>password </strong>field, and a signup button. We will also discuss the functionality where we first validate the form. So let&#39;s move on to the next block where we discuss about the CSS layout through which we design the beautiful layout.</p><h3>CSS Layout for the best and Professional Design</h3><p>This CSS layout includes a professional design layout. which includes design customization and transitions. We will start by editing the first section and once it&#39;s done we will start editing the second where we add the signup form to allow the user to <strong>sign up</strong> when someone clicks on the signup. we will also discuss the validation part in the next block. Let&#39;s see what type of transition effects we add in the popup. See the next block Where we discuss the popup effect section.</p><h3>Popup Effect in CSS for left and top Transitions</h3><p>In this section, we will discuss the left and top transitions. For adding transitions in the div elements we have to just focus on two type properties that are most useful in CSS when building some effect modules. <a href="https://css-tricks.com/almanac/properties/t/transform/">Transform </a>and <a href="https://css-tricks.com/almanac/properties/t/transition/">Translate</a>.</p><p>The div which we show as a popup model means in our case the second section in the main div we can add two types of classes hide-left-transition for the left model popup effect and hide-transition for the top model popup effect.</p><p>Same as for show-transition and show-left-transition in this way we add the effect inside our model so the CSS part is now fully clear don&#39;t worry you can watch the complete code implementation video on my YouTube channel check out the video on the last block of this post. Move onto the next block which is all about the javascript part where we handle buttons and sign-up form validation</p><h3>JavaScript Part including buttons integration with form validation</h3><p>Let&#39;s discuss the last part of this blog post which is all about the javascript integration in this project. JavaScript is the best language to add functionality to any element on the client side.</p><p>First, we make a default query selector function through which we can select the selectors easily in our case we have to render buttons, classes for CSS transitions, and form fields.</p><p>We will check if the all inputs are not empty then the model will hide out in any transition either left or top depending on you I show both of them in my YouTube video. if not then the model will stay and the message will be shown that please fill out the email and password fields to move on once it&#39;s done the login success message will be shown for 3 seconds and then the original message will Popup in this sense our custom sign-up model popup will be fully created.</p><h3>Steps to Follow</h3><ol><li>HTML Layout Structure (discussed in the first-second section)</li><li>CSS For Professional Design Layout</li><li>Discussion on the CSS design</li><li>JavaScript Integration</li><li>Sign-up Form Validation with effects handling</li><li>Final Message Popup on the success</li><li>That’s it</li></ol><h3>More Projects</h3><p>URL Shortener Tool in PHP Using Free Api (shrink) || <a href="https://malikcodex.blogspot.com/2024/01/url-shortener-tool-in-php-using-shrtlnk-api-for-free.html">See</a><br>Facebook Login Effect Sign-Up With Design and Features || <a href="https://malikcodex.blogspot.com/2024/01/create-facebook-login-page-with-design-and-features.html">See</a></p><h3>Youtube Video Tutorial</h3><p>See the full YouTube video clip where I show the complete implementation through live coding first read this complete post and then watch the full YouTube clip</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuJ3inOPrxwk&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuJ3inOPrxwk&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/afe44d8f3fb455cfd56ff670ccb5c987/href">https://medium.com/media/afe44d8f3fb455cfd56ff670ccb5c987/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29db8fd21897" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>