当我运行时,best_model = compare_models()CPU 内存负载巨大,而 GPU 却未得到利用。如何在 GPU 上运行setup()或compare_models()?PyCaret 中有内置方法吗?
我有一个Json列表,我想从给定的键打印所有键,直到字典结束.但是我写的代码非常复杂.如何以较低的复杂性做到这一点?我正在使用Python 3
dictionary = [{"a": "1"}, {"b": "2"}, {"c": "3"}, {"d": "4"}]
try:
for token in dictionary:
if "b" in list(token.keys())[0]:
new_dict = dictionary[len(list(token.keys())[0]):]
for i in new_dict:
print(new_dict[len(list(i.keys())[0]):])
break
else:
print("Inception")
except Exception as error:
print(str(error))
Run Code Online (Sandbox Code Playgroud)
希望
输入:b
输出:c,d
我的输出:
Inception
[{'c': '3'}, {'d': '4'}]
[{'c': '3'}, {'d': '4'}]
[{'c': '3'}, {'d': '4'}]
Run Code Online (Sandbox Code Playgroud)