brain.js
适用于浏览器和 Node.js 的 JavaScript GPU 加速神经网络
关于
brain.js
是一个用 JavaScript 编写的神经网络GPU 加速库。
💡 这是harthur/brain的延续,现已不再维护。更多信息
目录
安装和使用
新公共管理
如果您可以brain.js
使用npm安装:
npm install brain.js
CDN
<script src="//unpkg.com/brain.js"></script>
这是一个相当了不起的项目,它提供了一个用 JavaScript 编写的神经网络库。
下面是一个示例,展示了如何近似 README 中的 XOR 函数:
// provide optional config object (or undefined). Defaults shown.
const config = {
binaryThresh: 0.5,
hiddenLayers: [3], // array of ints for the sizes of the hidden layers in the network
activation: 'sigmoid' // supported activation types: ['sigmoid', 'relu', 'leaky-relu', 'tanh'],
leakyReluAlpha: 0.01 // supported for activation type 'leaky-relu'
};
// create a simple feed forward neural network with backpropagation
const net = new brain.NeuralNetwork(config);
net.train([{input: [0, 0], output: [0]},
{input: [0, 1], output: [1]},
{input: [1, 0], output: [1]},
{input: [1, 1], output: [0]}]);
const output = net.run([1, 0]); // [0.987]
它维护得很积极。绝对值得一试。
这篇文章是新版 GitHunt DEV 标签的一部分。关注此标签,了解更多类似内容。