model.add(layers.MaxPooling1D(pool_size=3)) ^ SyntaxError: invalid syntax
model.add(layers.MaxPooling1D(pool_size=3)) ^ SyntaxError: invalid syntax
model.add(layers.MaxPooling1D(pool_size=3))
^
SyntaxError: invalid syntax
我收到这个错误。问题是什么?我已经搜索过了,但发现几乎到处都是相同的语法
这是我的整个模型。模型中还有其他问题吗?我正在对音素进行语音识别
import tensorflow as tf
from keras import layers
from keras import models
model = models.Sequential()
#First Conv1D layer
model.add(layers.Conv1D(8,13, input_shape=(-1,8000,1), activation='relu',padding='valid', strides=1))
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True)(inputs))
#Second Conv1D layer
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1)
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1)
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True))
model.add(layers.Bidirectional(GRU(128, return_sequences=True), merge_mode='sum'))
model.add(layers.Bidirectional(GRU(128, return_sequences=True), merge_mode='sum'))
model.add(layers.Bidirectional(LSTM(128, return_sequences=False), merge_mode='sum'))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True))
#Flatten layer
model.add(layers.Flatten())
#Dense Layer 1
model.add(layers.Dense(256, activation='relu'))
model.add(layers.Dense(len(labels), activation="softmax"))
model.summary()
这条线
#Second Conv1D layer
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1)
您忘记关闭括号了。
改成这样
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1))
同样的错误出现在下面一行
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1)
要修复它,只需添加最后一个括号
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1))
model.add(layers.MaxPooling1D(pool_size=3))
^
SyntaxError: invalid syntax
我收到这个错误。问题是什么?我已经搜索过了,但发现几乎到处都是相同的语法
这是我的整个模型。模型中还有其他问题吗?我正在对音素进行语音识别
import tensorflow as tf
from keras import layers
from keras import models
model = models.Sequential()
#First Conv1D layer
model.add(layers.Conv1D(8,13, input_shape=(-1,8000,1), activation='relu',padding='valid', strides=1))
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True)(inputs))
#Second Conv1D layer
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1)
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1)
model.add(layers.MaxPooling1D(pool_size=3))
model.add(layers.Dropout(0.3))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True))
model.add(layers.Bidirectional(GRU(128, return_sequences=True), merge_mode='sum'))
model.add(layers.Bidirectional(GRU(128, return_sequences=True), merge_mode='sum'))
model.add(layers.Bidirectional(LSTM(128, return_sequences=False), merge_mode='sum'))
model.add(layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=1e-3, center=True, scale=True))
#Flatten layer
model.add(layers.Flatten())
#Dense Layer 1
model.add(layers.Dense(256, activation='relu'))
model.add(layers.Dense(len(labels), activation="softmax"))
model.summary()
这条线
#Second Conv1D layer
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1)
您忘记关闭括号了。
改成这样
model.add(layers.Conv1D(16, 11,activation='relu', padding='valid', strides=1))
同样的错误出现在下面一行
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1)
要修复它,只需添加最后一个括号
#Third Conv1D layer
model.add(layers.Conv1D(32, 9, activation='relu',padding='valid', strides=1))