質問編集履歴

13

訂正

2017/08/21 08:15

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -154,7 +154,7 @@
154
154
 
155
155
  for j in range(84):
156
156
 
157
- matcher = matching_hist(histtrain[j:j+1, 0:], histtest[i:i+1, 0:])
157
+ matcher = matching_hist(histtest[i:i+1, 0:], histrain[j:j+1, 0:])
158
158
 
159
159
  matcher = float(matcher)
160
160
 

12

質問の追加

2017/08/21 08:15

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -141,3 +141,27 @@
141
141
  ```
142
142
 
143
143
  上記のようなコードを書いて、(i=0,k=0)→(i=0,k=1)・・・(i=1,k=0)→(i=1,k=1)の順にループして、⓵を順に表示したいのですが,for i中のfor kのループが終わった後にfor i=i+1へのループに行かないのですが、どうしたらよいのでしょうか?
144
+
145
+
146
+
147
+ rat_lav[84-k][1]が全部0になっているのは
148
+
149
+
150
+
151
+ ```ここに言語を入
152
+
153
+ for i in range(84):
154
+
155
+ for j in range(84):
156
+
157
+ matcher = matching_hist(histtrain[j:j+1, 0:], histtest[i:i+1, 0:])
158
+
159
+ matcher = float(matcher)
160
+
161
+ #print(matcher)
162
+
163
+ rat_lav.append([matcher, i, j])
164
+
165
+ ```
166
+
167
+ この部分が原因になっているのでしょうか?

11

訂正

2017/08/21 08:13

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
16
16
 
17
- if countz + counto + counts=5:
17
+ if countz + counto + counts==5:
18
18
 
19
19
  #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
20
20
 

10

訂正

2017/08/21 07:55

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
16
16
 
17
- if 4<countz + counto + counts <6:
17
+ if countz + counto + counts=5:
18
18
 
19
19
  #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
20
20
 

9

現在動作中のコードに戻しました

2017/08/21 07:43

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -6,11 +6,17 @@
6
6
 
7
7
  for k in range(84):
8
8
 
9
+ print("value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
10
+
9
- if i==rat_lav[84-k][1] :
11
+ if i==rat_lav[84-k][1] :
10
12
 
11
13
  l = rat_lav[84-k][2]
12
14
 
15
+ #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
16
+
13
- if countz + counto + counts == 5:
17
+ if 4<countz + counto + counts <6:
18
+
19
+ #print("l:",l, "value:", rat_lav[84-k][0], "k:", k, "test.i:", i)
14
20
 
15
21
  className = {"0": "airplane",
16
22
 
@@ -68,9 +74,7 @@
68
74
 
69
75
  counto = 0
70
76
 
71
- counts = 0
77
+ counts = 0
72
-
73
- continue
74
78
 
75
79
  elif l<29:
76
80
 
@@ -83,12 +87,6 @@
83
87
  else:
84
88
 
85
89
  counts = counts + 1
86
-
87
-
88
-
89
-
90
-
91
-
92
90
 
93
91
  ```
94
92
 

8

情報の訂正

2017/08/21 07:41

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -104,7 +104,7 @@
104
104
 
105
105
  for k in range(84):
106
106
 
107
- if 条件式(i==a[84-k][1])
107
+ if i==a[84-k][1]:
108
108
 
109
109
  if 条件式
110
110
 

7

情報の訂正

2017/08/21 07:15

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -124,15 +124,17 @@
124
124
 
125
125
  for(k; k<84; k++){
126
126
 
127
- if 条件式(i==a[84-k][1])
127
+ if 条件式(i==a[84-k][1]){
128
128
 
129
- if 条件式
129
+ if 条件式 {
130
130
 
131
- ⓵表示するための式
131
+ } ⓵表示するための式
132
132
 
133
- else if 条件式
133
+ else if 条件式{
134
134
 
135
- else 条件式
135
+ }else 条件式{
136
+
137
+ }
136
138
 
137
139
  }
138
140
 

6

情報の訂正

2017/08/21 07:10

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -120,9 +120,9 @@
120
120
 
121
121
  ```ここに言語を入力
122
122
 
123
- for( i, i<84){
123
+ for( i i<84; i++){
124
124
 
125
- for(k, k<84){
125
+ for(k; k<84; k++){
126
126
 
127
127
  if 条件式(i==a[84-k][1])
128
128
 

5

情報の訂正

2017/08/21 07:06

投稿

bof
bof

スコア18

test CHANGED
@@ -1 +1 @@
1
- for文作り方ついて
1
+ for文作り方ついて
test CHANGED
File without changes

4

情報の修正

2017/08/21 07:00

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -112,9 +112,31 @@
112
112
 
113
113
  elif 条件式
114
114
 
115
- else 条件式
115
+ else 条件式
116
116
 
117
-
117
+ ```
118
+
119
+ pythonで実現したいことをC++で表現した場合
120
+
121
+ ```ここに言語を入力
122
+
123
+ for( i, i<84){
124
+
125
+ for(k, k<84){
126
+
127
+ if 条件式(i==a[84-k][1])
128
+
129
+ if 条件式
130
+
131
+ ⓵表示するための式
132
+
133
+ else if 条件式
134
+
135
+ else 条件式
136
+
137
+ }
138
+
139
+ }
118
140
 
119
141
  ```
120
142
 

3

情報の訂正

2017/08/21 06:59

投稿

bof
bof

スコア18

test CHANGED
@@ -1 +1 @@
1
- for文のbreakについて
1
+ for文に作り方ついて
test CHANGED
@@ -118,4 +118,4 @@
118
118
 
119
119
  ```
120
120
 
121
- 上記のようなコードを書いて、(i=0,k=0)→(i=0,k=1)・・・(i=1,k=0)→(i=1,k=0)の順にループして、⓵を順に表示したいのですが,i=0のループからi=1へのループに行かないのですが、どうしたらよいのでしょうか?
121
+ 上記のようなコードを書いて、(i=0,k=0)→(i=0,k=1)・・・(i=1,k=0)→(i=1,k=1)の順にループして、⓵を順に表示したいのですが,for ifor kのループが終わった後にfor i=i+1へのループに行かないのですが、どうしたらよいのでしょうか?

2

情報の訂正

2017/08/21 06:54

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -106,11 +106,11 @@
106
106
 
107
107
  if 条件式(i==a[84-k][1])
108
108
 
109
- if 条件式
109
+ if 条件式
110
110
 
111
- ⓵表示するための式
111
+ ⓵表示するための式
112
112
 
113
- elif 条件式
113
+ elif 条件式
114
114
 
115
115
  else 条件式
116
116
 

1

情報の詳細

2017/08/21 06:34

投稿

bof
bof

スコア18

test CHANGED
File without changes
test CHANGED
@@ -4,122 +4,118 @@
4
4
 
5
5
  for i, (classId, data_path) in enumerate(test_set):
6
6
 
7
- for j in range(350):
7
+ for k in range(84):
8
8
 
9
- for k in range(350):
9
+ if i==rat_lav[84-k][1] :
10
10
 
11
- countz = counto = counts = 0
11
+ l = rat_lav[84-k][2]
12
12
 
13
- if rat_lav[350-k][1] == j:
13
+ if countz + counto + counts == 5:
14
14
 
15
- l = rat_lav[350-j][2]
15
+ className = {"0": "airplane",
16
16
 
17
- if countz + counto + counts == 5:
17
+ "1": "ferry",
18
18
 
19
- break
19
+ "2": "laptop"}
20
20
 
21
- elif 0<l<293:
21
+ actual = "???"
22
22
 
23
- countz = countz + 1
23
+ if countz > counto and countz > counts:
24
24
 
25
- elif l<321:
25
+ actual = className["0"]
26
26
 
27
+ print("countz:", countz, "counto:", counto, "counts:", counts)
28
+
27
- cuonto = counto + 1
29
+ elif countz < counto and counts < counto:
30
+
31
+ actual = className["1"]
32
+
33
+ print("countz:", countz, "counto:", counto, "counts:", counts)
28
34
 
29
35
  else:
30
36
 
31
- counts = counto + 1
37
+ actual = className["2"]
38
+
39
+ print("countz:", countz, "counto:", counto, "counts:", counts)
32
40
 
33
41
 
34
42
 
35
- # 結果表示
43
+ result = ""
36
44
 
37
- className = {"0": "airplane",
45
+ if actual == "???":
38
46
 
39
- "1": "ferry",
47
+ result = " => unknown."
40
48
 
49
+ elif className[classId] == actual:
50
+
51
+ result = " => success!!"
52
+
53
+ success = success + 1
54
+
55
+ else:
56
+
41
- "2": "laptop"}
57
+ result = " => fail"
58
+
59
+ fail = fail + 1
42
60
 
43
61
 
44
62
 
45
- actual = "???"
63
+ print("expected: ", className[classId], ", actual: ", actual, result)
46
64
 
47
- if countz > counto and countz > counts:
65
+ #j=j+1
48
66
 
49
- actual = className["0"]
67
+ countz = 0
50
68
 
51
- elif countz < counto and counts < counto:
69
+ counto = 0
52
70
 
53
- actual = className["1"]
71
+ counts = 0
54
72
 
55
- else:
73
+ continue
56
74
 
57
- actual = className["2"]
75
+ elif l<29:
58
76
 
77
+ countz = countz + 1
59
78
 
79
+ elif l<57:
60
80
 
61
- result = ""
81
+ cuonto = counto + 1
62
82
 
63
- if actual == "???":
83
+ else:
64
84
 
65
- result = " => unknown."
66
-
67
- elif className[classId] == actual:
68
-
69
- result = " => success!!"
70
-
71
- success = success + 1
85
+ counts = counts + 1
72
-
73
- else:
74
-
75
- result = " => fail"
76
-
77
- fail = fail + 1
78
-
79
-
80
-
81
- print("expected: ", className[classId], ", actual: ", actual, result)
82
-
83
- print("suceess percentage:", success/(success+fail))
84
86
 
85
87
 
86
88
 
87
89
 
88
90
 
89
- ```iには画像が順番に入り,画像の数だけ
90
-
91
- ```ここに言語を入力
92
-
93
- print("expected: ", className[classId], ", actual: ", actual, result)
94
-
95
- ```
96
-
97
- を表示したいのですが、
98
-
99
- ```ここに言語を入力
100
-
101
- if countz > counto and countz > counts:
102
-
103
- ```
104
-
105
- 以降のcountz,counto,countsは
106
-
107
- ```ここに言語を入力
108
-
109
- if countz + counto + counts == 5:
110
-
111
- break
112
-
113
- ```
114
-
115
- ごとに
116
-
117
- ```ここに言語を入力
118
-
119
- if countz > counto and countz > counts:
120
-
121
91
 
122
92
 
123
93
  ```
124
94
 
95
+
96
+
125
- に反映させです。どのようにfor文を書けばこれが成立するかわかりません。お教えください。
97
+ くそなコードですません。
98
+
99
+ 要するに
100
+
101
+ ```ここに言語を入力
102
+
103
+ for i in range(84):
104
+
105
+ for k in range(84):
106
+
107
+ if 条件式(i==a[84-k][1])
108
+
109
+ if 条件式
110
+
111
+ ⓵表示するための式
112
+
113
+ elif 条件式
114
+
115
+ else 条件式
116
+
117
+
118
+
119
+ ```
120
+
121
+ 上記のようなコードを書いて、(i=0,k=0)→(i=0,k=1)・・・(i=1,k=0)→(i=1,k=0)の順にループして、⓵を順に表示したいのですが,i=0のループからi=1へのループに行かないのですが、どうしたらよいのでしょうか?