質問編集履歴
2
コード修正時のエラーについて
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,116 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
### 該当のソースコード 修正版
|
28
|
+
|
29
|
+
回答頂いたコードを元に変更すると、コンパイル時にエラーが発生しています。
|
30
|
+
|
31
|
+
layer.cでsse_ng_gpuにweight1, weight2を渡していますが、
|
32
|
+
|
33
|
+
渡し型の問題でしょうか?
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
main.cの// read values from fpで間違いなければ別の質問を
|
38
|
+
|
39
|
+
作成しようと思いましたが、元々の質問と繋がっているかもしれず
|
40
|
+
|
41
|
+
こちらでまずは確認させて頂きました。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
元々のコード記載ファイル(main.c)
|
46
|
+
|
47
|
+
```c
|
48
|
+
|
49
|
+
void parse_config(float* weight1, float* weight2)
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
char values[100+1];
|
54
|
+
|
55
|
+
char *filename;
|
56
|
+
|
57
|
+
long lines;
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
// read file
|
62
|
+
|
63
|
+
filename="test.cfg";
|
64
|
+
|
65
|
+
FILE* fp = fopen(filename, "r");
|
66
|
+
|
67
|
+
lines = fread(values, sizeof(float), 1, fp);
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
// read values from fp
|
72
|
+
|
73
|
+
sscanf(values, "%f %f\n", weight1, weight2);
|
74
|
+
|
75
|
+
//*weight1 =
|
76
|
+
|
77
|
+
//*weight2 =
|
78
|
+
|
79
|
+
fclose(fp);
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
上記を呼び出す別ファイル(layer.c)
|
88
|
+
|
89
|
+
```c
|
90
|
+
|
91
|
+
void forward_cost_layer(cost_layer l, network net)
|
92
|
+
|
93
|
+
if
|
94
|
+
|
95
|
+
//途中コード省略
|
96
|
+
|
97
|
+
else if(l.cost_type == SSE_NG){
|
98
|
+
|
99
|
+
float weight1 = 0.0;
|
100
|
+
|
101
|
+
float weight2 = 0.0;
|
102
|
+
|
103
|
+
parse_config(&weight1, &weight2);
|
104
|
+
|
105
|
+
sse_ng_gpu(l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, weight2);
|
106
|
+
|
107
|
+
} else {
|
108
|
+
|
109
|
+
l2_gpu(l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, weight2);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
エラー
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
./src/cost_layer.c: In function ‘forward_cost_layer’:
|
120
|
+
|
121
|
+
./src/cost_layer.c:147:95: error: incompatible type for argument 6 of ‘sse_ng_gpu’
|
122
|
+
|
123
|
+
l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, we
|
124
|
+
|
125
|
+
^
|
126
|
+
|
127
|
+
compilation terminated due to -Wfatal-errors.
|
128
|
+
|
129
|
+
Makefile:103: recipe for target 'obj/cost_layer.o' failed
|
130
|
+
|
131
|
+
make: *** [obj/cost_layer.o] Error 1
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
|
136
|
+
|
27
137
|
### 該当のソースコード
|
28
138
|
|
29
139
|
|
1
includeコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -29,6 +29,14 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
```c
|
32
|
+
|
33
|
+
#include <stdio.h>
|
34
|
+
|
35
|
+
#include <string.h>
|
36
|
+
|
37
|
+
#include <stdlib.h>
|
38
|
+
|
39
|
+
|
32
40
|
|
33
41
|
void parse_config(float* weight1, float* weight2)
|
34
42
|
|
@@ -106,6 +114,14 @@
|
|
106
114
|
|
107
115
|
```c
|
108
116
|
|
117
|
+
#include <stdio.h>
|
118
|
+
|
119
|
+
#include <string.h>
|
120
|
+
|
121
|
+
#include <stdlib.h>
|
122
|
+
|
123
|
+
|
124
|
+
|
109
125
|
int main(void) {
|
110
126
|
|
111
127
|
FILE *fp;
|