Show HN: 나는 첫 번째 신경망을 작성했습니다.
hackernews
|
|
📰 뉴스
#javascript
#ml구현
#머신러닝/연구
#신경망
#역전파
#자동미분
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
저자는 90년대부터 신경망에 관심을 가졌지만 이번에 Gemini의 도움을 받아 첫 번째 신경망 코드를 직접 작성했다. 특히 수식 라이브러리를 사용할 필요 없는 쌍수(Dual numbers)와 자동 미분 기법을 배우는 등 실질적인 지식을 얻었다. 이제 저자는 프로젝트를 TensorFlow를 활용한 심화 학습으로 확장할 계획이다.
본문
A full, multi-layer perceptron implemented in JavaScript. Uses dual numbers for auto-diff to perform backpropagation. Inspired by the excellent video series by Welch Labs on YouTube. - Automatic Differentiation: Uses a Dual Number implementation for exact gradients through a computation graph. - Multi-Layer Support: Flexible architecture defined by simple schema arrays (e.g., [2, 16, 1] ). - Layer Indexing: Direct access to individual layers via Proxy (e.g., p[0].activation = ... ). - Built-in Activations: RELU, SIGMOID, TANH, STEP, and IDENTITY. - Built-in Loss Functions: MSE, MAE, HUBER, and CROSS_ENTROPY. const { Perceptron } = require('./Perceptron.js'); // 1. Initialize: 2 inputs, 3 hidden neurons, 1 output const p = new Perceptron([2, 3, 1]); // 2. Configure layers (optional) // You can set activation globally: p.activation = Perceptron.RELU; // Or fine-tune per-layer using the Proxy: p[1].activation = Perceptron.SIGMOID; // 3. Forward pass const output = p.forward(0.5, -0.2); console.log(`Prediction: ${output[0][0].real}`); // 4. Training step p.backward([1.0]); // Backpropagate error relative to target p.update(0.1); // Apply gradients with learning rate TODO: - add metrics and visualization tools
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유