После создания GRU_model я попытался продолжить обучение с помощью fit(), но произошла ошибка
Это мой код `
import os
import tensorflow as tf
import librosa, librosa.display
from glob import glob
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers import Dense, SimpleRNN, GRU
from tensorflow.keras.optimizers import SGD
os.environ["CUDA_VISIBLE_DEVICES"]="0"
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
tf.config.experimental.set_memory_growth(gpus[0], True)
except RuntimeError as e:
print(e)
task = glob('./Dronenoise/task/*.wav')
print(task)
print(len(task))
def load_audio(audio_path):
audio, sr = librosa.load(audio_path, res_type='kaiser_fast')
mffcc = librosa.feature.mfcc(y=audio, sr=sr, n_mfcc=40)
pad2d = lambda a, i: a[:, 0:i] if a.shape[1] > i else np.hstack((a, np.zeros((a.shape[0], i-a.shape[1]))))
padded_mfcc = pad2d(mffcc, 600)
return padded_mfcc
mfccs = []
for i in range(len(task)):
mfccs.append(load_audio(task[i]))
a = np.array(mfccs[0:][0:][0:])
a.shape
(11, 40, 600)
a_train = a[0:10][:][:]
a_test = a[10:][:][:]
a_train.shape
(10, 40, 600)
a_test.shape
(1, 40, 600)
x_train, y_train= train_test_split(a_train, test_size=0.5, shuffle=False, random_state=42)
x_train = x_train.reshape(5, 600, 40)
y_train = y_train.reshape(5, 600, 40)
# The GRU architecture
my_GRU_model = Sequential()
my_GRU_model.add(GRU(units = 40,
return_sequences = True,
input_shape = (x_train.shape[1],40),
activation = 'tanh'))
my_GRU_model.add(GRU(units = 80,
activation = 'tanh'))
my_GRU_model.add(Dense(units = 40))
# Compiling the RNN
my_GRU_model.compile(optimizer = SGD(lr = 0.01, decay = 1e-7,
momentum = 0.9, nesterov = False),
loss = 'mean_squared_error')
# Fitting to the trainig set
my_GRU_model.summary()
Model: "sequential_15"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
gru_26 (GRU) (None, 600, 40) 9840
_________________________________________________________________
gru_27 (GRU) (None, 80) 29280
_________________________________________________________________
dense_11 (Dense) (None, 40) 3240
=================================================================
Total params: 42,360
Trainable params: 42,360
Non-trainable params: 0
_________________________________________________________________
c:\Users\kiyon\anaconda3\envs\Thesis\lib\site-packages\keras\optimizer_v2\optimizer_v2.py:356: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.
"The `lr` argument is deprecated, use `learning_rate` instead.")
my_GRU_model.fit(x_train, y_train, epochs = 50, batch_size = 8)
Это мой код ошибки
[[node mean_squared_error/SquaredDifference (defined at <ipython-input-198-c29cfba9c2a0>:1) ]] [Op:__inference_train_function_21423]
Function call stack:
train_function
`
Был сделан поиск, чтобы найти решение этой ошибки, но не удалось найти. В настоящее время я пытаюсь внедрить технологию активного шумоподавления с помощью ГРУ. При этом произошла следующая ошибка. Я сейчас очень простой человек. Поэтому хотелось бы получить отзыв об ошибке и коде в целом.