Forecast_generator的输出是什么意思?

时间:2020-06-15 16:33:44

标签: python keras

我正在尝试使用 predict_generator 来预测测试数据,并且当我用Google搜索时,我得到的输出是“ Numpy of arrays”,它说它们是概率。我不明白输出或值是什么。预测值的形状为(26,1)。

模型代码如下所示:

def build_model(maxlen, vector_dim, layers, dropout):

    print('Build model...')
    model = Sequential()

    model.add(Masking(mask_value=0.0, input_shape=(maxlen, vector_dim)))

    for i in range(1, layers):
        model.add(Bidirectional(GRU(units=256, activation='tanh', recurrent_activation='hard_sigmoid', return_sequences=True)))
        model.add(Dropout(dropout))

    model.add(Bidirectional(GRU(units=256, activation='tanh', recurrent_activation='hard_sigmoid')))
    model.add(Dropout(dropout))
model.compile(loss='binary_crossentropy', optimizer='adamax', metrics=['acc',km.precision(), km.recall(),km.true_positive(),km.false_positive(),km.false_negative()])

    model.summary()

    #plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

    return model

model = build_model(maxlen, vector_dim, layers, dropout)
print("Test1...")
    dataset = []
    labels = []
    testcases = []
    filenames = []
    funcs = []
    for filename in os.listdir(testdataSet_path):
        if(filename.endswith(".pkl") is False):
           continue
        print(filename)
        f = open(os.path.join(testdataSet_path, filename),"rb")
        datasetfile,labelsfile,funcsfiles,filenamesfile,testcasesfile = pickle.load(f)
        f.close()
        dataset += datasetfile
        labels += labelsfile
        testcases += testcasesfile
        funcs += funcsfiles
        filenames += filenamesfile
    print(labels)

    print(len(dataset), len(labels), len(testcases))

    bin_labels = []
    for label in labels:
        bin_labels.append(multi_labels_to_two(label))
    labels = bin_labels
    batch_size = 1
    test_generator = generator_of_data(dataset, labels, batch_size, maxlen, vector_dim)
    all_test_samples = len(dataset)
    steps_epoch = int(math.ceil(all_test_samples / batch_size))
    testGen = test_generator
    #testGen.reset()
    predictions = model.predict_generator(testGen,steps = steps_epoch,verbose=1)
    print(np.shape(predictions))
    print(predictions)

大量的数组是:

[[0.5308861 ]
 [0.5396905 ]
 [0.54187196]
 [0.5308773 ]
 [0.5308861 ]
 [0.48453102]
 [0.48453102]
 [0.4664028 ]
 [0.46451277]
 [0.72770065]
 [0.7277006 ]
 [0.66269165]
 [0.679774  ]
 [0.6405551 ]
 [0.64055496]
 [0.6311009 ]
 [0.64576715]
 [0.6826591 ]
 [0.70780784]
 [0.64045835]
 [0.64045817]
 [0.68670017]
 [0.6867001 ]
 [0.5396905 ]
 [0.54187196]
 [0.5308773 ]]

0 个答案:

没有答案