Python:
import keras
from keras.models import Sequential, Model
from keras.layers.embeddings import Embedding
from keras.layers import Input, Activation, Dense, Permute, Dropout,mer merge
from keras.layers import LSTM, GRU
from keras.utils.data_utils import get_file
from keras.preprocessing.sequence import pad_sequences
from keras import backend as K
from keras.layers import concatenate
from functools import reduce
import tarfile
import numpy as np
import re
import IPython
import matplotlib.pyplot as plt
import pandas as pd
input_sequence = Input((story_maxlen,))
question = Input((query_maxlen,))
print('Input sequence:', input_sequence)
print('Question:', question)
input_encoder_m = Sequential()
input_encoder_m.add(Embedding(input_dim=vocab_size,
output_dim=64))
input_encoder_m.add(Dropout(0.3))
input_encoder_c = Sequential()
input_encoder_c.add(Embedding(input_dim=vocab_size,
output_dim=query_maxlen))
input_encoder_c.add(Dropout(0.3))
question_encoder = Sequential()
question_encoder.add(Embedding(input_dim=vocab_size,
output_dim=64,
input_length=query_maxlen))
question_encoder.add(Dropout(0.3))
input_encoded_m = input_encoder_m(input_sequence)
print('Input encoded m', input_encoded_m)
input_encoded_c = input_encoder_c(input_sequence)
print('Input encoded c', input_encoded_c)
question_encoded = question_encoder(question)
print('Question encoded', question_encoded)
match = merge([input_encoded_m, question_encoded], mode='dot', dot_axes=(2, 2))
print(match.shape)
match = Activation('softmax')(match)
print('Match shape', match)
TypeError:
2 match = merge([input_encoded_m, question_encoded], mode='dot', dot_axes=(2, 2))
63 print(match.shape)
64 match = Activation('softmax')(match)
TypeError: 'module' object is not callable.
在keras中使用的合并功能。合并两个输入进行编码。该时间发生模块可调用错误。怎么解决