小编Ish*_*abi的帖子

Keras get_weights()返回空

我正在自学数据科学,有些东西引起了我的注意。在我正在研究的示例DNN教程中,我发现Keras layer.get_weights()函数返回了变量的空列表。我已经成功地交叉验证并使用model.fit()函数来计算召回得分。

但是,当我尝试对get_weights()分类变量使用该函数时,它将为所有函数返回空权重。

我不是在寻找代码的解决方案,而是对可能导致这种情况的方法感到好奇。我已经阅读了Keras API,但没有为我提供我希望看到的信息。是什么会导致get_weights()keras中的函数返回空列表,除了没有设置权重?

python machine-learning keras tensorflow

6
推荐指数
1
解决办法
718
查看次数

带有负数的 Python 排序列表

为了通过实践学习python,我正在尝试使用python实现和测试快速排序算法。

实现本身并不难,但是排序的结果有点令人费解:

当我对列表进行排序时

['35', '-1', '-2', '-7', '-8', '-3', '-4', '20', '-6', '53']

结果给了我

['-1', '-2', '-3', '-4', '-6', '-7', '-8', '20', '35', '53']

因此列表已排序,但负整数以相反的顺序排序。

我怀疑这可能是我正在对从文件中读取的整数列表进行排序这一事实的问题,并且 int 的类型实际上不是 int 而是其他的东西(也许是字符串。)我能做些什么来解决这个问题?

这是快速排序实现的代码

#quicksort -> the conquer part of the algorithm
def quicksort(input_list, start_index, end_index):
    if start_index < end_index:
        #partition the list of integers.
        pivot = partition(input_list, start_index, end_index)
        #recursive call on both sides of the pivot, that is excluding the pivot itself
        quicksort(input_list, start_index, pivot-1)
        quicksort(input_list, pivot+1, end_index)
    return input_list

#divide …
Run Code Online (Sandbox Code Playgroud)

python sorting quicksort negative-number python-2.7

5
推荐指数
1
解决办法
1万
查看次数