c-深度q学习程序退出,代码为-103741819



我正在c中编写一个深度q学习算法。我甚至编写了两个函数,一个初始化预测网络,另一个通过复制预测网络的权重和偏差来初始化目标网络。我试着通过打印初始化函数的权重来测试该函数,这就是控制台:

hello
memory successfully allocated
(process 12600) exited with code -1073741819.
Press any key to close this window . . .

代码:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define RAND_MAX 1
typedef struct neuron_t {
float activation;
float* outputWeights;
float bias;
float z;

}Neuron;
typedef struct layer_t {
int numberOfNeurons;
Neuron* neu;
}Layer;
int main() {

Layer* test = NULL;
int neus[] = { 3, 8, 8, 8, 4 };
createPredictionArchitecture(test, 5, neus);
for (int i = 0; i < 5; i++) {
for (int j = 0; i < test[i].numberOfNeurons; i++) {
for (int k = 0; k < test[i].neu[j].outputWeights[k]; i++) {
printf("n%fl", test[i].neu[j].outputWeights[k]);
}
}
}
return 0;
}
int createPredictionArchitecture(Layer* lay, int numberOfLayers, int* neuronsInEachLayer) {
printf("hellon");
lay = (Layer*)malloc(numberOfLayers * sizeof(Layer));

if (lay == NULL) {
printf("Failed to allocate memory in line 41n");
exit(0);
}
else
{
printf("memory successfully allocated");
}
for (int i = 0; i < numberOfLayers; i++) {
lay[i].numberOfNeurons = neuronsInEachLayer[i]; 
for (int j = 0; j < lay[i].numberOfNeurons; i++) {
lay[i].neu[j].bias = 0.01; // initializes the biases
if ((i + 1) < (sizeof(neuronsInEachLayer)-1)) {
for (int k = 0; k < lay[i+1].numberOfNeurons; k++) {
double a = rand() / (double)((RAND_MAX)) * 2 - 1;
double b = sqrt((2 / (lay[i].numberOfNeurons)));
lay[i].neu[j].outputWeights[k] = a * b; // initializes the weights
}
}
}
}
free(neuronsInEachLayer);
free(&numberOfLayers);
return 0;
}
int createTargetArchitecture(Layer* predictionNetwork, Layer* targetNetwork) {
targetNetwork = (Layer*)malloc(sizeof(predictionNetwork));
*targetNetwork = *predictionNetwork;
return 0;
}

如果有人能帮我解决这个问题就太好了。感谢

十六进制的退出代码-103741819为0xC0000005。如果你在微软的文档(NTSTATUS值(中查找此代码,你会发现它表明你的程序因访问违规而终止。出现此错误的原因多种多样,包括取消引用NULL指针或引用无效地址。

您应该在调试器中逐行遍历代码,以确定访问冲突发生的位置。这将使您能够分析情况并确定原因。

最新更新