gpt4 book ai didi

javascript - 神经网络无法处理给定的负载

转载 作者:行者123 更新时间:2023-12-03 12:04:56 25 4
gpt4 key购买 nike

我在网上找到了一些用 PHP 编写的神经网络的源代码。您可以在这里找到它:http://pastebin.com/MaqFXkWW

我认为这非常适合确定您在 Canvas 上绘制的内容是否以前绘制过。因此,我开始构建概念验证并构建此 neural_trainer.php脚本:

<? 
require_once ("class_neuralnetwork.php");

$pattern = $_POST['data'];

$n = new NeuralNetwork(90000, 90000, 1);
$n->setVerbose(false);

$n->addTestData($pattern, array (0));

$max = 9;


while (!($success = $n->train(1000, 0.01)) && $max -- > 0) {
echo "Nothing found...<hr />";
}


if ($success) {
$epochs = $n->getEpoch();
echo "Success in $epochs training rounds!<hr />";
}


for ($i = 0; $i < count($n->trainInputs); $i ++) {
$output = $n->calculate($n->trainInputs[$i]);
print "<br />Testset $i; ";
print "expected output = (".implode(", ", $n->trainOutput[$i]).") ";
print "output from neural network = (".implode(", ", $output).")\n";
}

这是 javascript,它发布到 neural_trainer.php

//canvas1 is 300x300
var img1Data = ctx1.getImageData(0,0,canvas1.width,canvas1.height);

$.ajax({
url: 'neural_training.php',
data: { data: img },
type: 'post',
success: function(data) {
console.log(data);
}
});

但它一直抛出 Allowed memory size of x bytes exhausted (tried to allocate x bytes)尽管我把它放在 class_neuralnetwork.php 的顶部ini_set("memory_limit","340M");
ini_set('max_execution_time', 1000);

最佳答案

PHP 可用的内存太小。通过 memory_limit 增加 PHP 可用的内存配置指令或重写脚本以消耗更少的内存。

关于javascript - 神经网络无法处理给定的负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25227524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com