質問編集履歴
2
コード修正時のエラーについて
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,6 +11,61 @@
|
|
11
11
|
|
12
12
|
まずは2つの数値をポインタ(float型)変数としてcfgファイルから読み込みたいとのですが、どのようにすれば宜しいでしょか。
|
13
13
|
|
14
|
+
### 該当のソースコード 修正版
|
15
|
+
回答頂いたコードを元に変更すると、コンパイル時にエラーが発生しています。
|
16
|
+
layer.cでsse_ng_gpuにweight1, weight2を渡していますが、
|
17
|
+
渡し型の問題でしょうか?
|
18
|
+
|
19
|
+
main.cの// read values from fpで間違いなければ別の質問を
|
20
|
+
作成しようと思いましたが、元々の質問と繋がっているかもしれず
|
21
|
+
こちらでまずは確認させて頂きました。
|
22
|
+
|
23
|
+
元々のコード記載ファイル(main.c)
|
24
|
+
```c
|
25
|
+
void parse_config(float* weight1, float* weight2)
|
26
|
+
{
|
27
|
+
char values[100+1];
|
28
|
+
char *filename;
|
29
|
+
long lines;
|
30
|
+
|
31
|
+
// read file
|
32
|
+
filename="test.cfg";
|
33
|
+
FILE* fp = fopen(filename, "r");
|
34
|
+
lines = fread(values, sizeof(float), 1, fp);
|
35
|
+
|
36
|
+
// read values from fp
|
37
|
+
sscanf(values, "%f %f\n", weight1, weight2);
|
38
|
+
//*weight1 =
|
39
|
+
//*weight2 =
|
40
|
+
fclose(fp);
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
上記を呼び出す別ファイル(layer.c)
|
45
|
+
```c
|
46
|
+
void forward_cost_layer(cost_layer l, network net)
|
47
|
+
if
|
48
|
+
//途中コード省略
|
49
|
+
else if(l.cost_type == SSE_NG){
|
50
|
+
float weight1 = 0.0;
|
51
|
+
float weight2 = 0.0;
|
52
|
+
parse_config(&weight1, &weight2);
|
53
|
+
sse_ng_gpu(l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, weight2);
|
54
|
+
} else {
|
55
|
+
l2_gpu(l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, weight2);
|
56
|
+
}
|
57
|
+
```
|
58
|
+
エラー
|
59
|
+
```
|
60
|
+
./src/cost_layer.c: In function ‘forward_cost_layer’:
|
61
|
+
./src/cost_layer.c:147:95: error: incompatible type for argument 6 of ‘sse_ng_gpu’
|
62
|
+
l.batch*l.inputs, net.input_gpu, net.truth_gpu, l.delta_gpu, l.output_gpu, weight1, we
|
63
|
+
^
|
64
|
+
compilation terminated due to -Wfatal-errors.
|
65
|
+
Makefile:103: recipe for target 'obj/cost_layer.o' failed
|
66
|
+
make: *** [obj/cost_layer.o] Error 1
|
67
|
+
```
|
68
|
+
|
14
69
|
### 該当のソースコード
|
15
70
|
|
16
71
|
```c
|
1
includeコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,6 +14,10 @@
|
|
14
14
|
### 該当のソースコード
|
15
15
|
|
16
16
|
```c
|
17
|
+
#include <stdio.h>
|
18
|
+
#include <string.h>
|
19
|
+
#include <stdlib.h>
|
20
|
+
|
17
21
|
void parse_config(float* weight1, float* weight2)
|
18
22
|
{
|
19
23
|
char values[100+1]
|
@@ -52,6 +56,10 @@
|
|
52
56
|
解決方法を教えて頂ければと思います。
|
53
57
|
|
54
58
|
```c
|
59
|
+
#include <stdio.h>
|
60
|
+
#include <string.h>
|
61
|
+
#include <stdlib.h>
|
62
|
+
|
55
63
|
int main(void) {
|
56
64
|
FILE *fp;
|
57
65
|
char *filename="sse_ng.cfg";
|