{"product_id":"n8n-webhook-ai-train-run-neural-network-with-code-nodes","title":"n8n Webhook AI: Train \u0026 Run Neural Network with Code Nodes","description":"\u003ch3\u003eTrain and run a neural network via Webhook—powered entirely by n8n Code nodes\u003c\/h3\u003e\n\u003cp\u003e\u003cstrong\u003en8n Webhook AI: Train \u0026amp; Run Neural Network with Code Nodes\u003c\/strong\u003e provides two production-ready webhook endpoints—one to \u003cstrong\u003etrain\u003c\/strong\u003e and one to \u003cstrong\u003epredict\u003c\/strong\u003e—using a feedforward neural network (three hidden ReLU layers) implemented with \u003cstrong\u003en8n Code\u003c\/strong\u003e. It persists learned weights in \u003cstrong\u003en8n workflow static data\u003c\/strong\u003e and returns class probabilities, predictions, and evaluation metrics as JSON.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eTraining webhook:\u003c\/strong\u003e Send a \u003ccode\u003ePOST\u003c\/code\u003e request to \u003ccode\u003e\/train\u003c\/code\u003e with \u003cem\u003eepochs\u003c\/em\u003e, \u003cem\u003elearning rate\u003c\/em\u003e, and an optional dataset. The workflow runs vectorized forward and backpropagation in JavaScript, updates weights\/biases via gradient descent, and stores them in workflow static data.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eInference webhook:\u003c\/strong\u003e Send a \u003ccode\u003ePOST\u003c\/code\u003e request to \u003ccode\u003e\/predict\u003c\/code\u003e with one or more \u003cstrong\u003e8-dimensional feature vectors\u003c\/strong\u003e (optionally including \u003cem\u003etrueClass\u003c\/em\u003e). It runs a feedforward pass through \u003cstrong\u003ethree ReLU hidden layers\u003c\/strong\u003e (9 neurons per layer), using stored weights or a deterministic fallback if none exist.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eProbabilities and metrics:\u003c\/strong\u003e The workflow computes output logits, applies \u003cstrong\u003etemperature-scaled softmax\u003c\/strong\u003e, and returns probabilities, predicted class, and confidence. When \u003cem\u003etrueClass\u003c\/em\u003e is provided, it calculates \u003cstrong\u003eper-sample cross-entropy loss\u003c\/strong\u003e and \u003cstrong\u003ebatch accuracy\u003c\/strong\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eExpose an internal ML model to other services through simple HTTP \u003cstrong\u003ewebhook-based inference\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eLet SaaS operators trigger model \u003cstrong\u003etraining\u003c\/strong\u003e with configurable epochs and learning rate, then immediately run \u003cstrong\u003epredictions\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003ePrototype and validate classification quality by returning \u003cstrong\u003eloss\u003c\/strong\u003e, \u003cstrong\u003eaccuracy\u003c\/strong\u003e, and probability distributions per sample.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n nodes:\u003c\/strong\u003e Webhook, Code, Merge, Respond to Webhook, and Sticky Note.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePersistence:\u003c\/strong\u003e learned weights stored in n8n workflow static data.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eInputs\/outputs:\u003c\/strong\u003e \u003ccode\u003e\/train\u003c\/code\u003e for epochs\/learning rate\/dataset; \u003ccode\u003e\/predict\u003c\/code\u003e for \u003ccode\u003ex: [8 numbers]\u003c\/code\u003e with optional \u003cem\u003etrueClass\u003c\/em\u003e, returning probabilities, prediction, confidence, and evaluation metrics.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45899965497523,"sku":"N8N-18693","price":36.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/sQyyDnuhyk0VnakxpxUW1_N8Q7TTHi.png?v=1787735791","url":"https:\/\/buyflowscripts.com\/products\/n8n-webhook-ai-train-run-neural-network-with-code-nodes","provider":"N8N Commerce","version":"1.0","type":"link"}