该层的所有输入应为张量

时间:2018-07-31 21:29:45

标签: python tensorflow keras

  

ValueError:使用非符号张量的输入调用了concatenate_1层。收到的类型:。全输入:[9]。该层的所有输入都应为张量。

paired_encoders_merger = concatenate(paired_encoder_size)行的问题

def __init__(self, input_size=18, paired_encoder_size=9, common_encoder_size=126, size_class=10):

    inputs = []
    [inputs.append(Input(shape=(input_size,1), name=('input_'+str(i)))) for i in range(7)]

    paired_encoders = []
    for i in range(7):
        paired_encoders.append(Dense(paired_encoder_size, activation='relu')(inputs[i]))

    paired_encoders_merger = concatenate(paired_encoder_size)
    common_encoder = Dense(common_encoder_size, activation='relu')(paired_encoders_merger)
    classes = Dense(size_class, activation='relu')(common_encoder)
    common_decoded = Dense(common_encoder_size, activation='relu')(classes)
    paired_decoded = []
    for i in range(7):
        paired_decoded.append(Dense(paired_encoder_size, activation='relu')(common_decoded))        

    out_pair = []

    for i in range(7):
        out_pair.append(Dense(input_size, activation='relu', name=('out_'+str(i)))(paired_decoded[i]))

    out_merger = concatenate(out_pair)

    self.model = Model(inputs=inputs,  outputs=out_merger)
    self.model.compile(optimizer='ADAM', loss='binary_crossentropy')

1 个答案:

答案 0 :(得分:0)

https://keras.io/layers/merge/#concatenate

您必须向PRCo EMPCOUNT udDivision PREndDate ROWNUM Type 1 89 Civil 2018-01-06 00:00:00 1 1 1 97 Civil 2018-01-13 00:00:00 2 1 1 97 Civil 2018-01-20 00:00:00 3 1 1 97 Civil 2018-01-27 00:00:00 4 1 1 16 Colorado 2018-01-06 00:00:00 1 1 1 18 Colorado 2018-01-13 00:00:00 2 1 1 14 Colorado 2018-01-20 00:00:00 3 1 1 10 Colorado 2018-01-27 00:00:00 4 1 1 94 Civil 2018-02-03 00:00:00 1 2 1 91 Civil 2018-02-10 00:00:00 2 2 1 92 Civil 2018-02-17 00:00:00 3 2 1 91 Civil 2018-02-24 00:00:00 4 2 1 16 Colorado 2018-02-03 00:00:00 1 2 1 16 Colorado 2018-02-10 00:00:00 2 2 1 18 Colorado 2018-02-17 00:00:00 3 2 1 19 Colorado 2018-02-24 00:00:00 4 2 1 92 Civil 2018-03-03 00:00:00 1 3 1 91 Civil 2018-03-10 00:00:00 2 3 1 88 Civil 2018-03-17 00:00:00 3 3 1 92 Civil 2018-03-24 00:00:00 4 3 1 90 Civil 2018-03-31 00:00:00 5 3 1 19 Colorado 2018-03-03 00:00:00 1 3 1 26 Colorado 2018-03-10 00:00:00 2 3 1 25 Colorado 2018-03-17 00:00:00 3 3 1 27 Colorado 2018-03-24 00:00:00 4 3 1 24 Colorado 2018-03-31 00:00:00 5 3 提供张量列表。您提供的是整数Concatenate()。尝试改为传递paired_encoder_size