TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Neural Network in 10 lines of C++ Code

6 pointsby PredictorYalmost 7 years ago

4 comments

poster123almost 7 years ago
It compiles and runs fine with g++, but when I try Microsoft&#x27;s cl.exe version 19.00 I get messages such as<p>xneural.cpp(22): error C2398: Element &#x27;1&#x27;: conversion from &#x27;double&#x27; to &#x27;float&#x27; requires a narrowing conversion<p>referring to the code<p><pre><code> vector&lt;float&gt; X { 5.1, 3.5, 1.4, 0.2, 4.9, 3.0, 1.4, 0.2, 6.2, 3.4, 5.4, 2.3, 5.9, 3.0, 5.1, 1.8 }; </code></pre> If I replace &lt;float&gt; with &lt;double&gt; the code compiles and runs with cl.exe.
评论 #17269013 未加载
asdsa5325almost 7 years ago
&gt; The core component of the code, the learning algorithm, is only 10 lines<p>AKA gradient descent in 10 lines of C++
horsawlarwayalmost 7 years ago
A neural network in 10 lines of C++ code... Plus another 200 lines of C++ code.<p>AKA: My &quot;lines of code&quot; count is super tiny if I don&#x27;t include function definitions!
rhodysurfalmost 7 years ago
Well thats a clickbait title... its nowhere near 10 lines