[英]Deep q-learning program exited with code -1073741819
我正在 c 中编写深度 q 学习算法。 我写了两个函数,一个初始化预测网络,另一个通过复制预测网络的权重和偏差来初始化目标网络。 我尝试通过打印出初始化的 function 的权重来测试 function,这是控制台:
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("hello\n");
lay = (Layer*)malloc(numberOfLayers * sizeof(Layer));
if (lay == NULL) {
printf("Failed to allocate memory in line 41\n");
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;
}
如果有人可以帮助我解决这个问题,那就太好了。 谢谢
十六进制的退出代码 -1073741819 是 0xC0000005。 如果您在 Microsoft 的文档( NTSTATUS 值)中查找此代码,您将看到它表明您的程序由于访问冲突而终止。 发生此错误的原因有多种,包括取消引用 NULL 指针或引用无效地址。
您应该在调试器中逐行检查代码以确定访问冲突发生的位置。 这应该使您能够分析情况并确定原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.