如何处理喀拉拉邦的None类型?

时间:2019-12-08 09:12:29

标签: keras

我想训练我的模型,但我不知道为什么name_list结果为None enter image description here

如果我忽略并将列表直接视为X,结果将变为: enter image description here

这是我的代码:

def name_method1(input):
    input = input.lower()

    output = []
    amount = []

    letter_order=[' ', 'a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 
                  'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '\'',
                  '.', ',', '(',')']


    for character in input:
        if character not in letter_order:
            break
        num = letter_order.index(character)
        amount += character

        if len(amount) > 30:
            break

        output.append(num)
        leng = len(output)
    while leng < 30:
        leng += 1
        output.append("0")

    print(output)
    return output
result_list = []
with open("athletes.csv", 'r') as f:
    dataset = csv.reader(f)
    next(dataset)
    for row in dataset:
        name = row[0]
        nationality = row[1]
        name_list = name_method2(name)
        result_list.append(name_list)
    f.close()

print(result_list)

    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X, y, epochs=150, steps_per_epoch=1)

_, accuracy = model.evaluate(X, y)

print('Accuracy: %.2f' % (accuracy*100))

# fit the keras model on the dataset
model.fit(X, y, epochs=150, batch_size=10, verbose=0)

如何纠正?

0 个答案:

没有答案