python中output尺寸过小怎么办_TypeError:“output_size”缺少1个必需的位置参数

嗨,我面对下面的错误。请告诉我怎么做。在

我遇到了与model.add(TimeDistributedDense(self.output_size))中的参数相关的错误from __future__ import print_function

from keras.preprocessing import sequence

from keras.models import Sequential

from keras.layers.core import Activation, RepeatVector, TimeDistributedDense, Dropout, Dense

from keras.layers import recurrent

from keras.layers.embeddings import Embedding

import numpy as np

from preprocessing import preprocess

import pdb

RNN = recurrent.LSTM

class seq2seq(object):

# Initialize model parameters

def __init__(self, input_size, seqlen, output_size, input_dim = 100, \

hidden_dim = 200):

self.maxlen = seqlen

self.input_size = input_size

self.output_size = output_size

self.input_dim = input_dim

self.hidden_dim = hidden_dim

def seq2seq_plain(self):

# Plain seq2seq

model = Sequential()

model.add(Embedding(self.input_size , self.input_dim))

model.add(RNN(self.hidden_dim, return_sequences=True))#, input_shape=(100, 128)))

model.add(Dropout(0.25))

model.add(RNN(self.hidden_dim))

model.add(RepeatVector(self.maxlen))

#model.add(RNN(self.hidden_dim, return_sequences=True))

#model.add(Dropout(0.25))

model.add(RNN(self.hidden_dim, return_sequences=True))

model.add(TimeDistributedDense(self.output_size))

model.add(Dropout(0.5))

model.add(Activation('softmax'))

model.compile(loss='categorical_crossentropy', optimizer='adam',

metrics=['accuracy'])

return model

def seq2seq_attention(self):

raise NotImplementedError

if __name__ == "__main__":

# Test the model

seq2seq = seq2seq(15, 5500)

seq2seq.train_seq2seq()

错误:

^{pr2}$

你可能感兴趣的:(python中output尺寸过小怎么办_TypeError:“output_size”缺少1个必需的位置参数)