質問するログイン新規登録

質問編集履歴

3

脱字

2021/12/17 08:26

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -28,7 +28,30 @@
28
28
 
29
29
  ```Python
30
30
  f_train_path = os.getcwd() + '/feature/Session' + fold + '/train/'
31
+
32
+ def hard_label(path):
31
- # 省略
33
+ label=[]
34
+ f_list = list(ii for ii in sorted(glob.glob(path)))
35
+ for file_path in f_list:
36
+ with open(file_path, 'r') as file:
37
+ for line in file:
38
+ line_sp = line.replace('Happiness', '0')
39
+ line_sp = line_sp.replace('Anger', '1')
40
+ line_sp = line_sp.replace('Neutral', '2')
41
+ line_sp = line_sp.replace('Sadness', '3')
42
+ line_sp = line_sp.replace('\n', '')
43
+ line_sp = line_sp.split(',')
44
+ if (len(line_sp)==10):
45
+ if (line_sp[9] == '0') or (line_sp[9] == '1') or (line_sp[9] == '2') or (line_sp[9] == '3'):
46
+ label.append(line_sp[9])
47
+ print(line_sp[0])
48
+
49
+ file.close()
50
+ label = np.array(label)
51
+ label = label.astype('int16')
52
+ #print(label)
53
+ return label
54
+
32
55
  def load_data(path):
33
56
  f_list = list(sorted(glob.glob(path + '*.npy')))
34
57
  X = np.zeros((len(f_list), slen, f_dim), dtype='float32')
@@ -39,11 +62,9 @@
39
62
  X[ii] = np.vstack((tmp, padd))
40
63
  return X.reshape(len(X), slen, f_dim, 1)
41
64
 
42
- # 省略
43
65
  print(x_train.shape, y_train.shape)
44
66
  print(x_test.shape, y_test.shape)
45
67
 
46
- # 省略
47
68
  # Trains the model for a fixed number of epochs (iterations on a dataset)
48
69
  model_history = model.fit(x=x_train,
49
70
  y=y_train,
@@ -55,7 +76,6 @@
55
76
  callbacks=[valid_metrics, chkPoint]
56
77
  )
57
78
 
58
- # 省略
59
79
  def main():
60
80
  x_train = load_data(f_train_path)
61
81
  ```

2

誤字

2021/12/17 08:26

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  PythonでCNNモデルを用い音声感情分類を行うシステムを作っています。
4
4
  以下のエラーメッセージが発生しました。xとyのサイズを揃えないといけないと思うのですが、
5
- どう修正すれば良いか調べてみても分からなかったため、どなたご教授いただけませんでしょうか?
5
+ どう修正すれば良いか調べてみても分からなかったため、どなたご教授いただけませんでしょうか?
6
6
 
7
7
  ### 発生している問題・エラーメッセージ
8
8
 

1

誤字

2021/12/16 08:34

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -7,6 +7,8 @@
7
7
  ### 発生している問題・エラーメッセージ
8
8
 
9
9
  ```
10
+ (637, 2913, 40, 1) (762, 4)
11
+ (450, 2913, 40, 1) (450, 4)
10
12
  Traceback (most recent call last):
11
13
  File "cnn_model.py", line 329, in <module>
12
14
  main()
@@ -38,6 +40,10 @@
38
40
  return X.reshape(len(X), slen, f_dim, 1)
39
41
 
40
42
  # 省略
43
+ print(x_train.shape, y_train.shape)
44
+ print(x_test.shape, y_test.shape)
45
+
46
+ # 省略
41
47
  # Trains the model for a fixed number of epochs (iterations on a dataset)
42
48
  model_history = model.fit(x=x_train,
43
49
  y=y_train,