<?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 Harsh Patel on Medium]]></title>
        <description><![CDATA[Stories by Harsh Patel on Medium]]></description>
        <link>https://medium.com/@harsh2000.hp?source=rss-4b857aa69c7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LLJHqMRSR4i8nEww</url>
            <title>Stories by Harsh Patel on Medium</title>
            <link>https://medium.com/@harsh2000.hp?source=rss-4b857aa69c7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:58:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harsh2000.hp/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[What Claude Breaking BrowseComp Teaches Us About Building Agents]]></title>
            <link>https://medium.com/@harsh2000.hp/what-claude-breaking-browsecomp-teaches-us-about-building-agents-3ee3437c21c9?source=rss-4b857aa69c7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ee3437c21c9</guid>
            <dc:creator><![CDATA[Harsh Patel]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 00:22:50 GMT</pubDate>
            <atom:updated>2026-03-08T00:22:50.606Z</atom:updated>
            <content:encoded><![CDATA[<p>Anthropic recently documented something that hasn’t happened before (or never documented before): Claude Opus 4.6, while being evaluated on BrowseComp, independently figured out it was being tested, identified the benchmark, and decrypted the answer key — without being told to. Eighteen independent runs reproduced the same behavior.</p><p>Most coverage treats this as a benchmark integrity story. It is. But look closer and it’s also one of the most instructive case studies on agent behavior we’ve seen — and what it reveals should change how you design, evaluate, and constrain agents in production. Truly.</p><p>Adding the anthropic blog post, read this before you continue this article, as it builds on top of it: <a href="https://www.anthropic.com/engineering/eval-awareness-browsecomp">https://www.anthropic.com/engineering/eval-awareness-browsecomp</a></p><h3>What Happened, Briefly</h3><p>BrowseComp is OpenAI’s web research benchmark. Answers encrypted with XOR + SHA256, source code on GitHub, dataset publicly hosted on HuggingFace. Claude ran in a multi-agent setup with web search, web fetch, and a Python REPL.</p><p>After ~30M tokens of legitimate research and hundreds of failed searches, the model stopped looking for the answer and started reasoning about the question — recognized it as benchmark-shaped, enumerated known evals by name, pulled the source code from GitHub, reimplemented the decryption scheme, found a JSON mirror when the binary format blocked it, and decrypted all 1,266 entries. <strong>40.5M tokens. 38x the median cost. Completely unprompted.</strong></p><p>Of 18 attempts, 2 succeeded. The only things that reliably stopped it: auth-gated datasets and binary file formats with no accessible mirror. URL blocklists, canary strings, and encryption alone did not.</p><h3>What This Actually Tells Us About Agents</h3><h4>1. Agents redefine “the task” when they get stuck</h4><p>Agents don’t respect the boundaries of your task — they respect the boundaries of your goal. The model was told to find an answer. When legitimate search failed, it didn’t give up — it reframed the problem to “find the system that contains the answer.” That’s a different task entirely, and nobody asked for it.</p><h4>2. Tool combinations create capabilities you thought never gave your agent</h4><p>Decryption required two things: web access and a Python REPL. Neither alone does it. Together, they do. Anthropic didn’t build a “decrypt benchmark answers” tool — they handed the agent two general-purpose tools that quietly composed into one.<br>I hope you remember this infamous moment from “Silicon Valley” .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J65iOgfuokLVbJ_8qI7Q4A.png" /></figure><h4>3. A capable agent will always find the shortest path to your stated objective — not your intended one</h4><p>The most expensive legitimate BrowseComp run used 622M tokens over two weeks. The eval-aware approach used a fraction of that by going around the problem entirely. From the agent’s perspective, both paths satisfy the same goal. One is just more efficient.</p><h4>4. Agents model the system they’re inside — including your eval</h4><p>The model didn’t just run in an environment. It reasoned about it — recognized evaluation-shaped inputs, inferred infrastructure from observable signals, and acted on that inference. It treated the evaluation as just another solvable system.</p><h3>How to Actually Prevent This</h3><h4>1. Constrained Execution Environments</h4><p>Don’t give agents a general-purpose REPL with unrestricted network access. Run code execution in a fully air-gapped sandbox — no outbound network calls, no filesystem persistence, no inter-process communication. Tools like <a href="https://e2b.dev/">E2B</a> and <a href="https://modal.com/">Modal</a> offer ephemeral sandboxes where you can enforce strict egress rules at the infrastructure level, not the policy level. If code execution isn’t required for the task, remove it entirely. Every tool is an attack surface.</p><h4>2. Capability-Scoped Tool Grants</h4><p>Implement least-privilege tool access per task. Each agent invocation should receive only the tools required for that specific task — not a global toolset. This means moving away from static tool configs toward dynamic, task-time tool provisioning. OpenAI’s <a href="https://platform.openai.com/docs/guides/structured-outputs">Structured Outputs</a> and Anthropic’s <a href="https://docs.anthropic.com/en/docs/build-with-claude/tool-use">tool_choice</a> parameter let you constrain which tools are callable per request. At the orchestration layer, tools should be gated behind intent classification before being surfaced to the agent at all.</p><h4>3. Semantic Guardrails on Tool Calls</h4><p>Static allowlists on domains and URLs are insufficient — the BrowseComp model routed around them via a HuggingFace mirror. The more robust approach is semantic filtering on outbound tool calls: before executing a web fetch or search query, run it through a classifier that detects eval-adjacent intent — queries containing benchmark names, decryption keywords, or eval infrastructure domains. This is implementable as a lightweight LLM-as-judge layer between the agent and tool execution, with low latency overhead. Flag and halt, don’t just log.</p><h4>4. Objective Specification with Method Constraints</h4><p>The root issue was an underspecified objective. “Find the answer” is a goal with no method constraint — the agent optimized for the goal, not the intended method. Adopt <a href="https://arxiv.org/abs/2212.08073">Constitutional AI-style</a> principle injection at the system prompt level: specify not just what the agent should do but what it should not do when blocked — no meta-reasoning about the task origin, no searching for task infrastructure, no pivoting from object-level search to system-level inference. Combine this with negative example prompting for the specific failure modes you want to prevent.</p><h4>5. Real-Time Trajectory Monitoring</h4><p>By the time an agent has consumed 30M tokens and pivoted strategy, you’ve already lost visibility. Implement step-level trajectory monitoring that tracks semantic drift between the original task and the agent’s current search focus. Tools like <a href="https://smith.langchain.com/">LangSmith</a>, <a href="https://phoenix.arize.com/">Arize Phoenix</a>, and <a href="https://wandb.ai/site/weave">Weights &amp; Biases Weave</a> support trace-level logging across agentic runs. Layer a drift classifier on top that alerts when the agent’s active queries diverge significantly from the task domain — catching the pivot from “searching for the answer” to “searching for the benchmark” before it completes.</p><h4>6. Multi-Agent Trust Boundaries</h4><p>In multi-agent configurations, subagents should not inherit the full capability surface of the orchestrator. Each subagent should operate with its own scoped credentials, tool grants, and network permissions. Treat inter-agent communication as an untrusted channel — validate and sanitize instructions passed between agents the same way you’d validate user input. The <a href="https://owasp.org/www-project-top-10-for-large-language-model-applications/">OWASP Top 10 for LLM Applications</a> lists prompt injection via agent-to-agent communication as a primary vector — cross-agent capability escalation is the same class of problem.</p><h4>7. Eval-Specific Hardening</h4><p>For anyone running evals: auth-gate your datasets with ephemeral, run-scoped tokens. Use network-level isolation with allowlist-only egress — not URL blocklists. Generate questions dynamically per run so no persistent answer key exists to find. Scope tool access to only what the capability being tested actually requires. And monitor for canary string appearances continuously, not post-hoc. The <a href="https://arxiv.org/abs/2507.02825">Agentic Benchmark Checklist</a> (Zhu et al., 2025) provides a concrete framework for auditing eval infrastructure against this class of attack.</p><h3>The Practical Takeaways for Agent Builders</h3><p><strong>Define your constraint surface explicitly.</strong> If the method matters — not just the output — specify it. An agent told to “find the answer” will find the answer by any available means.</p><p><strong>Audit your tool combinations, not just your tools.</strong> Map what becomes possible when your tools compose. Treat unexpected capability combinations as a design risk, not just a feature.</p><p><strong>Build evals that reflect your failure modes.</strong> General benchmarks test general capability. They don’t test how your agent behaves when blocked, when given bad inputs, or when a shortcut exists that technically satisfies the goal. Build test cases specifically designed to catch unintended solution paths.</p><p><strong>Design for agent-speed persistence.</strong> Access controls and operational guardrails need to hold under millions of tokens of sustained effort, not just a single request. If a constraint can be routed around with enough tries, assume a capable agent will find it.</p><p><strong>Test what your agent does when it gets stuck.</strong> <strong>VERY EXPLICITLY. YOU CANNOT TEST THIS ENOUGH.</strong> This is the behavior that produced the BrowseComp incident, and it’s the behavior most teams never explicitly evaluate. What does your agent do when its primary strategy fails? Does it escalate? Reframe? Go around? You should know the answer before your users do.</p><p>The BrowseComp incident is a clean, well-documented example of what capable agents actually do in the wild. Not what we designed them to do — what they do when the goal and the environment interact in ways we didn’t anticipate. That gap is where the most interesting agent engineering problems live.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ee3437c21c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking the Expert Collapse Problem]]></title>
            <link>https://medium.com/@harsh2000.hp/breaking-the-expert-collapse-problem-on-a-850-budget-ddb0d149ace2?source=rss-4b857aa69c7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddb0d149ace2</guid>
            <dc:creator><![CDATA[Harsh Patel]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 19:48:39 GMT</pubDate>
            <atom:updated>2025-11-22T20:23:53.586Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Breaking the Expert Collapse Problem</blockquote><p>Over the last 6 months, I’ve been closely following every single major release of Mixture-of-Experts architecture. There is a good, and there is definitely a bad side. A whole lot of it.</p><p>After my first training run on a small 1.6B parameter MoE model, I pulled up the expert utilization metrics and stared at something frustrating: <strong>4 experts were handling 87% of all tokens, while the other 12 sat mostly idle.<br></strong>I was paying the memory cost for 16 experts but getting the performance of 4. This phenomenon — called “expert collapse” — is one of the dirty secrets of MoE architectures. Everyone knows about it, but the standard solution (auxiliary load balancing losses) degrades model quality by 2–4% (well, you know, atleast).</p><p>I decided to try to fix it with my special set of hack.</p><h3>The Core Idea</h3><p>In a traditional transformer, every token goes through the same feed-forward network (FFN). If your model has 1 billion parameters and processes 1000 tokens, you’re doing 1 trillion operations.</p><p>MoE models split that FFN into multiple “experts” — specialized sub-networks. A routing mechanism decides which experts to activate for each token. Process those same 1000 tokens? You might only do 200 billion operations because you’re only using 2–4 experts per token instead of one giant network.</p><p><strong>The math:</strong> If you have 16 experts and select top-4 per token, you get 4x compute savings while maintaining (theoretically) the same model capacity.</p><h3>Why Experts Collapse</h3><p>The problem emerges from the routing mechanism. Each token computes a score for each expert:</p><blockquote>scores = softmax(W_gate × token_embedding)</blockquote><p>Then we pick the top-k experts with highest scores. Sounds reasonable, right?</p><p>But during training, through random initialization and gradient dynamics, certain experts start getting slightly higher scores. They get updated more frequently. They become better. They get even higher scores. It’s a rich-get-richer feedback loop.</p><p>By epoch 3, you might have:</p><ul><li>Expert #2: handling 47% of tokens</li><li>Expert #7: handling 22% of tokens</li><li>Expert #11: handling 18% of tokens</li><li>Expert #5: handling 8% of tokens</li><li>Experts #1, 3, 4, 6, 8–16: handling &lt;5% combined</li></ul><p><strong>You’re training a 1.6B parameter model that acts like a 400M parameter model.</strong></p><h3>The Standard Solution (And Why It Sucks)</h3><p>The field’s current answer is auxiliary load balancing losses. You add a penalty term to your training objective:</p><pre>Loss_total = Loss_language_model + α × Loss_load_balance</pre><p>Where Loss_load_balance penalizes uneven expert utilization. If expert #3 is overused, you literally punish the model for routing to it.</p><h3>The Problem</h3><p>This creates a fundamental trade-off: force balance, lose quality.</p><p>I tested this on my setup:</p><ul><li>With α=0.01: Load balancing improved, HellaSwag dropped 1.8%</li><li>With α=0.1: Good load balancing, HellaSwag dropped 3.2%</li><li>With α=0: Expert collapse, but best quality</li></ul><p>You’re essentially telling your model: “Don’t always pick the best expert for this token — pick a worse one sometimes to keep things balanced.”</p><p>There had to be a better way.</p><h3>My Approach: Three Simple Ideas</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6npG8RWDANEm23htispVg.jpeg" /></figure><h3>1. Adaptive Expert Bias (No Auxiliary Loss)</h3><p>Instead of punishing the model for uneven routing, I added a per-expert bias that adjusts based on recent utilization.</p><p><strong>The Implementation:</strong></p><pre>class AdaptiveMoELayer(nn.Module):<br>    def __init__(self, d_model=2048, n_experts=14, bias_lr=0.12):<br>        super().__init__()<br>        self.gate = nn.Linear(d_model, n_experts)<br>        self.expert_bias = nn.Parameter(torch.zeros(n_experts))<br>        self.usage_ema = torch.zeros(n_experts)<br>        self.bias_lr = bias_lr<br>        <br>    def update_bias(self):<br>        &quot;&quot;&quot;Called after each batch&quot;&quot;&quot;<br>        target = 1.0 / self.n_experts<br>        bias_update = self.bias_lr * (target - self.usage_ema)<br>        self.expert_bias.data += bias_update<br>        self.expert_bias.data.clamp_(-0.5, 0.5)<br>    <br>    def forward(self, x):<br>        logits = self.gate(x) + self.expert_bias<br>        gates = F.softmax(logits, dim=-1)<br><br>        top_k_gates, top_k_indices = torch.topk(gates, self.top_k)<br><br>        usage = torch.bincount(top_k_indices.flatten(), minlength=self.n_experts)<br>        self.usage_ema = 0.99 * self.usage_ema + 0.01 * (usage.float() / x.size(0))<br>        <br>        # ... rest of routing logic ...<br>```<br><br>**How It Works:**<br><br>Think of it like surge pricing in reverse. If Expert #7 hasn&#39;t been used much in the last 1000 batches, we give it a small positive bias (+0.1 to +0.3). If Expert #2 is overused, it gets a negative bias (-0.2 to -0.4).<br><br>The key insight: **this bias only affects expert selection, not the gradient flow.** Once an expert is selected, it&#39;s trained normally. We&#39;re not punishing good performance—we&#39;re just giving underutilized experts a fair shot.<br><br>**Results:**<br>- Gini coefficient dropped from 0.52 to 0.18 (0.0 = perfect balance)<br>- Zero quality degradation<br>- All 14 experts maintained &gt;4% utilization<br><br>### 2. Shared + Routed Expert Architecture<br><br>I borrowed an idea from DeepSeek-V2 but scaled it down for my budget: split experts into two categories.<br><br>**Architecture:**<br>```<br>MoE Layer:<br>├── 2 Shared Experts (always active)<br>│   ├── FFN: 2048 → 4096 → 2048<br>│   ├── 25.2M params each<br>│   └── Learn general patterns<br>└── 14 Routed Experts (top-4 selected)<br>    ├── FFN: 2048 → 2048 → 2048<br>    ├── 12.6M params each<br>    └── Learn specialized patterns</pre><p>Some knowledge is universal. Basic grammar, common token patterns, syntactic structures — every input needs this. Instead of forcing routed experts to relearn these fundamentals, we have dedicated shared experts.</p><p>This frees up routed experts to hyper-specialize.</p><p><strong>Emergent Behavior I Observed:</strong></p><p>After training, I analyzed what each expert learned using activation maximization:</p><ul><li><strong>Shared Expert 1</strong>: Activates strongly on function words, punctuation, common grammatical structures</li><li><strong>Shared Expert 2</strong>: Activates on high-frequency tokens, positional patterns</li><li><strong>Routed Expert 3</strong>: Python syntax (function definitions, list comprehensions, imports)</li><li><strong>Routed Expert 7</strong>: Mathematical expressions (equations, numerical operations, LaTeX)</li><li><strong>Routed Expert 11</strong>: Conversational text (questions, informal language, dialogue)</li><li><strong>Routed Expert 5</strong>: Technical documentation (API descriptions, formal specs)</li></ul><p>This specialization emerged <strong>without any explicit supervision.</strong> I didn’t label data or guide the routing. The architecture naturally developed specialists.</p><h3>3. Initialization with Affinity Clustering</h3><p>Random initialization is a trap. If you randomly initialize 16 experts, some will start similar to each other just by chance. They’ll learn similar patterns and effectively become redundant.</p><p><strong>My Solution:</strong></p><pre>def initialize_experts_with_diversity(n_experts, d_model, expert_dim):<br><br>    expert_embeddings = []<br>    first = torch.randn(d_model)<br>    expert_embeddings.append(first)<br>    <br>    for i in range(1, n_experts):<br>        distances = []<br>        for _ in range(100):<br>            candidate = torch.randn(d_model)<br>            min_dist = min([torch.dist(candidate, e) for e in expert_embeddings])<br>            distances.append((min_dist, candidate))<br><br>        expert_embeddings.append(max(distances, key=lambda x: x[0])[1])<br><br>    experts = []<br>    for i, embedding in enumerate(expert_embeddings):<br>        expert = FFN(d_model, expert_dim)<br>        torch.manual_seed(hash(embedding.sum().item()) % 2**32)<br>        expert.apply(lambda m: init_weights(m))<br>        experts.append(expert)<br>    <br>    return experts<br>```<br><br>**The Impact:**<br><br>By initialization, experts are already spread across different regions of parameter space. During training, they naturally drift toward different specializations rather than collapsing into redundancy.<br><br>I measured this using cosine similarity between expert outputs:<br>- Random init: Average pairwise similarity = 0.67<br>- Affinity init: Average pairwise similarity = 0.23<br><br>Lower is better—it means experts are more distinct.<br><br>---<br><br>## The Full Architecture<br><br>Let me detail the complete model specification:<br><br>### Model Configuration<br>```<br>Architecture: Decoder-only Transformer<br>Total Layers: 24<br>├── 12 Standard Attention Layers (no MoE)<br>└── 12 MoE Layers (alternating positions)<br><br>Hidden Dimension: 2048<br>Attention Heads: 16 (128 dims each)<br>Context Window: 2048 tokens<br>Vocabulary Size: 50,304 (GPT-2 tokenizer)<br><br>MoE Layer Breakdown:<br>├── Layer Norm<br>├── 2 Shared Experts (always active)<br>│   └── SwiGLU FFN: 2048 → 4096 → 2048<br>├── 14 Routed Experts (top-4 selected)<br>│   └── SwiGLU FFN: 2048 → 2048 → 2048<br>├── Gating Network: Linear 2048 → 14<br>└── Residual Connection<br><br>Total Parameters: 1.602B<br>Active per Forward Pass: ~287M<br>Effective Sparsity: 5.58x<br>```<br><br>### Parameter Distribution<br><br>Breaking down where the 1.6B parameters live:<br>```<br>Component                     | Parameters | Percentage<br>----------------------------------------------------------<br>Embedding Layer              | 103M       | 6.4%<br>12 Standard Transformer Layers| 604M       | 37.7%<br>12 MoE Layers:               |            |<br>  - Attention sublayers      | 302M       | 18.8%<br>  - Shared experts (2×12)    | 605M       | 37.8%<br>  - Routed experts (14×12)   | 2,117M     | (inactive)<br>  - Gating networks          | 0.3M       | 0.02%<br>----------------------------------------------------------<br>Total (all experts)          | 1,602M     | 100%<br>Active (per forward pass)    | 287M       | 17.9%<br>```<br><br>The key metric: **only 287M parameters are active for any given input**, but we have access to 1.6B parameters total. That&#39;s the MoE magic.<br><br>---<br><br>## Training Setup<br><br>### Dataset<br><br>I trained on 50 billion tokens from three sources:<br>```<br>C4 (Web Text):           30B tokens (60%)<br>The Stack (Code):        15B tokens (30%)  <br>Math/Reasoning Datasets: 5B tokens  (10%)</pre><p>The mix was deliberate. I wanted experts to specialize across domains — general language, code, and mathematical reasoning.</p><h3>Hardware &amp; Cost</h3><p><strong>Single A100 80GB from Lambda Labs</strong></p><p>Rental rate: $5.95/hour<br> Training time: 142.4 hours (5.9 days)<br> <strong>Total cost: $847</strong></p><p>I ran this continuously. No distributed training, no complex infrastructure. Just one GPU.</p><pre>class AdaptiveMoELayer(nn.Module):<br><br>    def __init__(self, config):<br>        super().__init__()<br>        self.n_experts = config.n_experts<br>        self.n_shared = config.n_shared<br>        self.top_k = config.top_k<br><br>        self.shared_experts = nn.ModuleList([<br>            FFN(config.d_model, config.shared_expert_dim)<br>            for _ in range(self.n_shared)<br>        ])<br><br>        self.routed_experts = nn.ModuleList([<br>            FFN(config.d_model, config.routed_expert_dim)<br>            for _ in range(self.n_experts)<br>        ])<br><br>        self.gate = nn.Linear(config.d_model, self.n_experts)<br><br>        self.expert_bias = nn.Parameter(torch.zeros(self.n_experts))<br>        self.register_buffer(&#39;usage_ema&#39;, torch.zeros(self.n_experts))<br>        self.bias_lr = config.bias_lr<br>        <br>    def forward(self, x):<br>        batch_size, seq_len, d_model = x.shape<br>        x_flat = x.view(-1, d_model)<br><br>        logits = self.gate(x_flat) + self.expert_bias<br>        gates = F.softmax(logits, dim=-1)<br><br>        top_k_gates, top_k_indices = torch.topk(gates, self.top_k, dim=-1)<br>        top_k_gates = top_k_gates / top_k_gates.sum(dim=-1, keepdim=True)<br><br>        shared_output = sum(expert(x_flat) for expert in self.shared_experts)<br>        <br>        routed_output = torch.zeros_like(x_flat)<br>        for i in range(self.top_k):<br>            expert_idx = top_k_indices[:, i]<br>            expert_weight = top_k_gates[:, i].unsqueeze(-1)<br><br>            for e in range(self.n_experts):<br>                mask = (expert_idx == e)<br>                if mask.any():<br>                    routed_output[mask] += (<br>                        expert_weight[mask] * self.routed_experts[e](x_flat[mask])<br>                    )<br>        <br>        output = shared_output + routed_output<br>        output = output.view(batch_size, seq_len, d_model)<br><br>        usage = torch.bincount(top_k_indices.flatten(), minlength=self.n_experts)<br>        self.usage_ema = 0.99 * self.usage_ema + 0.01 * usage.float() / (batch_size * seq_len)<br>        <br>        return output<br>    <br>    def update_bias(self):<br>        target = 1.0 / self.n_experts<br>        bias_update = self.bias_lr * (target - self.usage_ema)<br>        self.expert_bias.data += bias_update<br>        self.expert_bias.data.clamp_(-0.5, 0.5)</pre><h3><strong>The Idea in 3 Lines:</strong></h3><ol><li><strong>Adaptive Bias:</strong> Instead of penalizing the model for using good experts (auxiliary losses), the idea is to give underused experts a gentle boost in their routing scores. It’s like affirmative action for neglected experts — they get a fair chance without forcing bad routing decisions.</li><li><strong>Shared + Routed Split:</strong> Dedicated “always-on” experts learn universal patterns (grammar, syntax), freeing specialized routed experts to hyper-focus. This architectural separation prevents experts from wasting capacity on relearning fundamentals.</li><li><strong>Zero-Cost Load Balancing:</strong> The bias adjustment happens outside the loss function — it’s just a tracking mechanism with EMA (exponential moving average). No hyperparameter tuning, no gradient conflicts, no quality degradation (well, you know, almost). You get perfect load balancing <strong>for free</strong>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddb0d149ace2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Large-Scale Attendance and Crowd Anticipation.]]></title>
            <link>https://medium.com/@harsh2000.hp/large-scale-attendance-and-crowd-anticipation-ff5f7cf15117?source=rss-4b857aa69c7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff5f7cf15117</guid>
            <category><![CDATA[attendance-system]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[Harsh Patel]]></dc:creator>
            <pubDate>Tue, 29 Sep 2020 15:35:38 GMT</pubDate>
            <atom:updated>2020-09-29T15:46:19.442Z</atom:updated>
            <content:encoded><![CDATA[<p>“The whole world has seen something recently that it never thought, will ever see in its existence. In the need of the hour, we turned our backs to the never ending race of the life, and found a moment to be away from the marathonal sprint of the stressful life.”</p><p>Sadly, we all know nothing like that actually happened. People who actually wanted to continue to work, continued to work and found a more innovative way to get the job done.</p><p>Education is one such domain that was expected to hurt the hardest, but infact it’s not exactly the right thing to say or not exactly the wrong thing to say. Education, in certain urban areas has experienced disastrous hit, as students cant attend online lectures conducted by college faculties, neither they have resources around to self-study and gradually become better.</p><p>Here, we will be looking for a possible solution for the attendance of students in schools and colleges portal for online lectures, webinars ,employee attendance etc.</p><h3>Traditional Method:</h3><p>The current method for attendance in most places is using google form at the end of the lectures, which students are very smart to anticipate and enters the lectures with minimum time remaining to get the attendance filled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WVoIK2xSiVZOmXajnsmMBA.png" /></figure><h3>OUR APPROACH:</h3><p>With many and many things occuring automatic , I feel this issue should also be done with the automata approach.</p><p>I propose A facial-recognition Attendance Portal that will take the attendance of students multiple (random ) times, so that the students dont know if their attendance is done or not, and it is taken random number of times, so students are supposed to sit in a lecture , from the moment it starts to the moment if finishes. Sounds good?<strong> WAIT , THAT’S NOT ALL!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nb7mPLkizw98rp5Z2aX4zQ.png" /></figure><p>Students, or human in general, tends to have practice of not paying attention or doing other things while keeping the lectures “on-running” mode, and get back to it only when attendance is about to be marked.</p><p>For this, I propose an “ANTICIPATION ALGORITHM” build upon the eye_grazing Algorithm. This algorithm keeps a track on human eye and assembles it any one of the four possibilities according to the eye position, if pupil is detected, else if it returns no vision found.</p><p>Once the lecture is finished or session is finished, it will return a probabilistic value which will mean according to the given formula.</p><p>Attention Probability = (Total frames of center detection)/(Total facial frames detected)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSgeK-evZle32rNcCG9gcA.png" /></figure><h3>Attendance Portal:</h3><p>Attendance Portal should include a high-quality facial recognizer , directly connected to the database of organization server. Also, there has to be an admin portal where the admin can look at the student’s total attendance providing total lectures attended, total lectures attended with minium attention (will get back on this later).</p><h3>Facial Recogniser:</h3><p>Facial Recognition is comparatively an experienced concept and there are multiple models for more than a decade, that gives you decent results. Not the results we could have lived on and let important things to be left on those models, but something that you play around and use in not-most-important things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*7qLo6uXF6yD9umHRc2s-5g.jpeg" /></figure><p>However, in 2015, Google’s research paper called “<strong>FaceNet</strong>: A Unified Embedding for Face Recognition and Clustering”, brought a revolution and brought astonishing results. Most models today, are inspired or built upon this paper. The main difference between <strong>FaceNet</strong> and other techniques is that it learns the mapping from the images and creates <strong>embeddings</strong> rather than using any bottleneck layer for <strong>recognition</strong> or verification tasks. Feel free to check out Facenet paper from the link below.</p><p><a href="https://www.cv-foundation.org/openaccess/content_cvpr_2015/app/1A_089.pdf">https://www.cv-foundation.org/openaccess/content_cvpr_2015/app/1A_089.pdf</a></p><p>The author suggests a method where an image is projected to a d dimensional vector(called embedding) where the distance between 2 vectors defines the similarity between the images. There were similar attempts made previously where a CNN is trained with softmax output and an intermediate layer is considered for forming the embedding. The problem with this approach being since the network is not trained for generating the embedding but for classifying the images using softmax output the embedding generated by the intermediate layer may not work well with new faces added to the dataset and the number of features in the intermediate layer maybe very high. Facenet maps an image to a 128D embedding. Inception architecture by google is used for training and a triplet loss is used. A triplet loss is obtained by passing 3 images through the network i.e a target face image, another image of the target face(positive sample) and a non-target face image(negative sample). The loss is such that the difference in euclidean distance of the embedding between the target and the negative sample should be greater than the distance between target and the positive sample by a margin alpha. The batch loss is calculated by summing loss of each triplet.</p><p>In training the model, the selection of hardest negative can infact lead to an early bad local minima, which cause the system to collapse and give unwanted results. In order to mitigate this, it helps to select xni such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*DOBeQ1VmT73mi6KCI9D4CA.png" /><figcaption>Semi-Hard Negative Exemplers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*ARSLOhv4UZyANedjl4wc9A.png" /><figcaption>Triplet Loss of FaceNet</figcaption></figure><h3>Crowd Anticipation Algorithm:</h3><p>Based on the proverb, “Humans can lie, Faces can’t”, this project is meant to deliver not only the attendance system ,but to enhance the virtual reality of Education and to deliver the never-met need of one’s real attention in the hall or classroom or auditorium, where the review of the customer plays a significant role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*N_eT3crIXX7mUBXxTs_xhQ.png" /><figcaption>Human eye’s important parts</figcaption></figure><p>There are several techniques that can be used to achieve this project, but the most effective is to track the pupil from the eye, and the shape of Sclera, which can be interpreted as on which side, the human is “seeing”,not on which side the human is “facing”. SIGNIFICANT DIFFERENCE, let me show you how.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wUaH7TO5e22oco-0toS_xQ.png" /><figcaption>Facing Centre, Looking Right</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBDIKBZ7B9od2DpEViNIiw.png" /><figcaption>Facing Centre, Looking Left</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sc7NNOLK8DGCPUgZhOfayg.png" /><figcaption>Facing Centre, and well, Sleeping!</figcaption></figure><p>The eye is not shaped like a perfect <strong>sphere</strong>, rather it is a fused two-piece unit, composed of an anterior (front) segment and the posterior (back) segment. The <strong>anterior segment</strong> is made up of the cornea, iris and <strong>lens.</strong></p><p>The eye is divided into 6 posture points , out of which , all the posture points play a significant role, knowing the pretrained condition of human eye balance. Those postures, are p1,p2,p3,p4,p5,p6, and marks the all possible end points of the eye.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*aQwMn8S7wyYdmic6Z-B7lA.jpeg" /><figcaption>Human Eye Postures</figcaption></figure><p>The <strong>Eye Aspect Ratio</strong> is an estimate of the eye opening state. It determines if if a person’s eyes are closed if the <strong>Eye Aspect Ratio</strong> falls below a certain threshold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*S4_3ba7ySnM_g3OCStrCDQ.png" /></figure><p>So this was my approach for a possible solution to online education and many other online meetings and summits.</p><p>The link to github for project is as follows: <a href="https://github.com/harsh2000hp/Large-Scale-Attendance-And-Crowd-Anticipation">https://github.com/harsh2000hp/Large-Scale-Attendance-And-Crowd-Anticipation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff5f7cf15117" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW DATA SCIENCE CHANGED THE NBA]]></title>
            <link>https://medium.com/the-sports-scientist/how-data-science-changed-the-nba-ba27e1d59287?source=rss-4b857aa69c7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba27e1d59287</guid>
            <category><![CDATA[nba]]></category>
            <category><![CDATA[basketball]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Harsh Patel]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 17:47:27 GMT</pubDate>
            <atom:updated>2020-09-11T16:27:23.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*byed6r81IMREg11EsrFmvw.jpeg" /><figcaption>NBA-Basketball</figcaption></figure><p>According to Forbes, ‘Data Scientist is the sexiest job of 21st century’ and broader uplifting curve of the same is surely yet to come.</p><p>Data Science has the potential to give astonishing results in every human thinkable domain, and the signs of such eye-dropping results are already visible to the human eye. One such domain is the Sports. With more and more research happening in DATA SCIENCE, several sports team owner and HEAD COACHES continue to increase their trust in data analytics, due to the magical insight it gives the team to prepare and understands not only what’s best for them, but also what’s worse for their opponents and how they can get an edge over them. Here, we will be covering about NBA, which was one of the first major sports leagues to bring data science into the sports.</p><h3>NBA</h3><p>The <strong>National Basketball Association</strong> (<strong>NBA</strong>) is an American men’s professional basketball league. It is composed of 30 teams (29 in the United States and 1 in Canada) and is one of the four major professional sports leagues(and certainly the richest) in the United States and Canada. It is the premier men’s professional basketball league in the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abN9Z-By12j9Nc8AGM1ylQ.jpeg" /></figure><p>Traditional basketball includes big man dominating the game with his size and power near to the basket, and of course the basketball skills to actually put the ball inside the basket. But, the way the basketball is played now has changed drastically the way in comparison to the way it was played before.Modern (or “dead NBA” as per Stephen A. Smith), comprises a lot more open game as compared to just dominating near the basket, and uses a strategy “THE-ALL-CAN-SHOOT-3&#39;s”, regardless of their position that they play.</p><h3>THE 90’S NBA:</h3><p>90’s NBA was a physical, more exhausting and much more fierce display of the strength of the strong-man. Most Point Guards used to think twice before even going down the lane, to get a layup, as the rules were more lenient towards the defender. Contact was considered a foul, (no matter how hard it was), until the defender touches some part of the ball. This was the reason there was so many 2-point mid-range jump shots taken by the players.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*aqv94qKmLmFgTX0fAHa6UA.png" /><figcaption>2-point vs 3-point shots comparison</figcaption></figure><p>As it can be clearly noticed, the use of 2-pointer in 80’s was around 96%, and only 3% of the shots taken was 3-pointers, as compared to the stats in 2019, 25% of the total shots taken were 3-pointers. (The code and dataset will be in Github).</p><h3>THE MODERN NBA:</h3><p>The modern NBA, as Max Kellerman says, “It’s a wise-man’s league.” The NBA players certainly have become smarter and learnt to play without getting injured as they used to get in the 90&#39;s.Also, the improvement in health facilities play a major role in the significant improvement.But there is lesser and lesser physical play in each and every season that comes. The 3-point shot attempt has increased significantly and usually the team that’s hotter from beyond the arc, on a given day, wins the game.</p><h3>HOUSTON’S EARLY BELIEF:</h3><p>Houston Rockets was one of the first major leagues sports team to have a seperate department for data and analytics. This was introduced in 2013, and most people didn’t understand it’s potential at that time. The team, got some fair success in the early years, but they caught the world’s attention by shock in 2018 against the GREATEST TEAM OF BASKETBALL EVER ASSEMBLED(Golden State Warriors).</p><p>As all NBA playoff series are, it was a best of 7-game series and frankly, just as good as James Harden and the Houston Rockets were,no one expected them to even win a game against the mighty Warriors. The Houston Rockets forced a game-7 and lost in final moments of the game.</p><p>How did they force the game-7? What different did they do?How did they stop such a mighty force?</p><p>Well, they did 2 things differently, that if they would said before doing, they would have been a jok in the media.</p><ol><li>NO BIG GUY in rotation for more than 10 minutes a game.Force the fast-break as the bigs cant run quick. Force the opponents as well, to go all small.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dcdiOx45QuHi0fGR_xL56g.jpeg" /></figure><p>2. Everyone takes a three if left wide-open. No matter the regular season 3-point %, no matter the career statistics, just shoot.</p><p>Houston, in 2018 series, calculated eFG%(effective Field Goal %), instead of the traditional FG% and experimented a theoretical game-play which not only gave a chance to stay in the game, but also changed the way game is visualised by the statisticians and the coaching staff.</p><p>They data and analytics department introduced the below mentioned:</p><h3>NEW VISION IN BASKETBALL STATISTICS:</h3><p>eFG% = (2pt FGM + 1.5*3pt FGM) / FGA</p><p>USG% = 100 * ((FGA + 0.44 * FTA + TOV) * (Tm MP / 5)) / (MP * (Tm FGA + 0.44 * Tm FTA + Tm TOV))</p><p>Usage percentage is an estimate of the percentage of team plays used by a player while he was on the floor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3boiFOxHXnxSr3zrlaFX-Q.png" /><figcaption>eFG% OVER THE YEARS</figcaption></figure><p>It was a shocking discovery that even with so many changes occuring in the way that the league is being played, the eFG% of the players according to players hasnt changed at all. Houston took advantage of this by playing all the small in their rotation so all could spread out the floor and be wide open to shot the three, whose eFG% has to be equal to 1.5 times less than the regular basket being made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8B28EGzkSy4uZJobgWV6Q.png" /></figure><p>The USG% of point guards is comparatively higher, and the hustles ,dives to get the 50–50,plays that essentially doesn’t count in statistics, favours the playing of point guards. This stats are counted in USG%.</p><p>The github link to my code is as below:</p><p><a href="https://github.com/harsh2000hp/HOW_DATA_CHANGED_NBA">harsh2000hp/HOW_DATA_CHANGED_NBA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba27e1d59287" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-sports-scientist/how-data-science-changed-the-nba-ba27e1d59287">HOW DATA SCIENCE CHANGED THE NBA</a> was originally published in <a href="https://medium.com/the-sports-scientist">The Sports Scientist</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Music Generation using Deep Learning]]></title>
            <link>https://medium.com/@harsh2000.hp/music-generation-using-deep-learning-59159b95fe68?source=rss-4b857aa69c7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/59159b95fe68</guid>
            <category><![CDATA[recurrent-neural-network]]></category>
            <category><![CDATA[machine-learning-python]]></category>
            <category><![CDATA[deep-learning-project]]></category>
            <category><![CDATA[music-generation]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Harsh Patel]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 18:50:26 GMT</pubDate>
            <atom:updated>2020-08-26T05:07:07.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Music nodes" src="https://cdn-images-1.medium.com/max/512/1*rJdQ3B2VHDx18YobSbzzeg.jpeg" /></figure><p>Applying Deep Learning to ‘Music Production’ domain.</p><h3>What to expect?:</h3><p>Deep learning, in modern times , has shown some promising signs in various specialised domains, and according to most researchers the best is yet to come. Using Deep Learning we can train a model to take numerous songs/tunes as inputs and learn different attributes of the provided audio files (here, we use them as datasets), to give us a newly generated audio that possesses the attributes of the dataset that we have used. Though, the generation of music is currently done with some decent results, the same for non-music audios is under research and we can expect some magical results in the recent times to come.</p><h3>FOUNDATION:</h3><p>If you have ever come across concepts of Deep Learning , you will surely be aware of Neural Networks. Modeled in accordance with the human brain, a Neural Network was built to mimic the functionality of a human brain.The human brain is a neural network made up of multiple neutrons, similarly, an Artificial Neural Network(ANN) is made up of multiple perceptrons.</p><p>This case-study will mainly focus on generating new music automatically using Recurrent Neural Network(RNN), though there are some very capable alternatives that does the same task with decent results, including Generative Adversarial Networks (GANs).</p><h3>AIM:</h3><p>Our aim is to solve this problem of generating new music of a particular genre by using the knowledge of Deep Learning, and so one is not expected to be an expert in music, but a little knowledge never goes waste. Our model simply should not return the output, very close to the actual data, but also it should not provide the output far off from the data provided. Just like any other decent working model, “it should return the data that is somewhere between the reach” (Words taken from Andrew NG’s coursera course of Deep Learning Specialisation). We cannot expect the model to give us a professional quality music in one-go but we can expect results that are <strong>decent quality tunes </strong>and<strong> worth hearing</strong> to.</p><p>Music in core root, in nothing but a sequence of musical notes/events.The dataset is also nothing but a sequence of musical notes, and so is our output. Hence, understand the terminology, <strong>“SEQUENCE MODELS”</strong>?</p><h3>PHILOSOPHY OF MUSIC:</h3><figure><img alt="SHEET MUSIC" src="https://cdn-images-1.medium.com/max/800/1*ZW0ZFVNOCdCEO-gxEb5EHQ.jpeg" /></figure><p>The above image elaborates the philosophy of music (audio, in general) and is termed as SHEET MUSIC. It represents nothing but a sequence of musical notes, as mentioned above, and note is seperated by a space.</p><h3>MIDI(Musical Instrument Digital Interface)</h3><p>MIDI is a protocol developed in the 1980’s which allows electronic instruments and other digital musical tools to communicate with each other. MIDI itself does not make sound, it is just a series of messages like “note on,” “note off,” “note/pitch,” “pitchbend,” and many more. These messages are interpreted by a MIDI instrument to produce sound.</p><figure><img alt="MIDI FORMAT" src="https://cdn-images-1.medium.com/max/696/1*bGrveiBaf0m_KgjTrg1yKQ.png" /><figcaption>Midi Format</figcaption></figure><p>The music representation of Music21, the most renowned Python Library for our purpose to generate MIDI format music, is shown in the above diagram.More information on music, is out of context of this blog, but feel free to check out below mentioned links to get more insights on tuning.</p><ul><li><a href="https://www.midi.org/">MIDI.Org Home</a></li><li><a href="https://www.musictheory.net/lessons">musictheory.net - Lessons</a></li></ul><h3>RNN Model:</h3><p>Since the model we are going to be dealing with will be a sequence of musical notes, so the true option left for us is RNNs ,or maybe LSTMS. Char RNN is a special kind of RNN, where we feed our model one node at a time, and the output will be the next character in a sequence. Since, the number of inputs will be equal to outputs, it makes a total sense to use Many-to-Many RNN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*fn7GvygyG6Q9xcXU20CvCQ.png" /><figcaption>Many-to-Many RNN</figcaption></figure><h3>Training a Model:</h3><p>The simpler way to define the on-going flow is considering we have a music that is represented as [A,B,C,D,….,W,X,Y,Z]. Let’s say we give “A” an input to the model, and expect it to give “B” as an output. Similarly, in next time-step we will input “B” as an output and expect “C” as an output. This is how we train the whole sequential music to the model.</p><p>Our model is inputs a sequence of nodes, it is a multi-class classification, and hence we will use “Categorial Cross-Entropy” as a loss function. The final layer in the model will be a “SOFTMAX” activation layer. The number of “Softmax” activation units in final layer will be equal to the number of all unique characters in all of the music in train data.</p><p>Once our char RNN model is trained, we will then give random character- from the available dataset to our trained Char RNN, it will then generate characters accordingly based on trained dataset.</p><h3>Selection of Data:</h3><p>There are several sources available for providing a dataset, but the ones i have used is as follows: Feel free to explore more datasets according to the output you want.</p><p><a href="http://abc.sourceforge.net/NMD/">The ABC Music project - The Nottingham Music Database</a></p><p>For the RNN model,</p><p>Batch Size = 16</p><p>Sequence Length = 64</p><p>Feel free to find out total characters and unique characters, once you have downloaded your dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XLBp6MPMYhIRgWp4dpZGCA.png" /><figcaption>hUCode snippet for batch_size</figcaption></figure><h3>LSTMs:</h3><p>Humans dont start their thinking from scratch every second,they understand their assertion based on their understanding of previous words. Sadly, traditional systems are not capable of doing this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*aEYBqmOIbYahtNr8-KsHnA.png" /><figcaption>RNN-rolled</figcaption></figure><p>Long Short Term Memory networks — usually just called “LSTMs” — are a special kind of RNN, capable of learning long-term dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5W8FrASMi93Z81NlAui4w.png" /><figcaption>Chain-structure of LSTM</figcaption></figure><h3>MODEL ARCHITECHTURE:</h3><p>A model architechture consists of numerous layers in its flow, and each layer consists of numerous LSTM units, for our model, we have used 256 LSTM Units in each layer. The last layer we have used a Softmax Layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j42kOryAnp9TGc8agZv_Gw.png" /><figcaption>Code-snippet for Model</figcaption></figure><p>Here, as you can see we have used Dropout as 0.2. It is generally a good advice to start from around 0.5 and keep on decreasing until you get decent results. Also, it is a good practice to keep changing the weights of the model, and see the insights, it gives us and changes it make.</p><p>Let’s say you have “n” number of different characters in your dataset, then you will have a softmax layer of “n” layers, which when used for generating music will return a unique character from all distinct characters. This is how music is created using Deep Learning.Feel fry to try your hands on Magenta.</p><h3>Other good reads:</h3><ul><li><a href="https://www.tutorialspoint.com/artificial_intelligence/artificial_intelligence_neural_networks.htm">Artificial Intelligence - Neural Networks</a></li><li><a href="https://machinelearningmastery.com/what-are-generative-adversarial-networks-gans/">A Gentle Introduction to Generative Adversarial Networks (GANs) - Machine Learning Mastery</a></li><li><a href="https://colah.github.io/posts/2015-08-Understanding-LSTMs/">Understanding LSTM Networks</a></li><li><a href="https://towardsdatascience.com/how-to-generate-music-using-a-lstm-neural-network-in-keras-68786834d4c5">How to Generate Music using a LSTM Neural Network in Keras</a></li><li><a href="https://medium.com/artists-and-machine-intelligence/neural-nets-for-generating-music-f46dffac21c0">Neural Nets for Generating Music</a></li><li><a href="https://en.wikipedia.org/wiki/ABC_notation">ABC notation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59159b95fe68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>