Python Jupyter笔记本错误!他死了。它将自动重新启动
错误:内核似乎已死亡。它将自动重新启动。这是特定于几行代码的 当我尝试Python Jupyter笔记本错误!他死了。它将自动重新启动,python,python-3.x,jupyter-notebook,anaconda,jupyter-console,Python,Python 3.x,Jupyter Notebook,Anaconda,Jupyter Console,错误:内核似乎已死亡。它将自动重新启动。这是特定于几行代码的 当我尝试print(3)时,我在控制台中看到输出为3,但当我尝试运行时,下面的代码会给我一个错误。它工作得非常完美,突然抛出了这些奇怪的错误 我尝试重新启动、重新安装和升级所有库,但没有任何效果 import numpy as np versicolor_petal_length = np.array([4.7, 4.5, 4.9, 4., 4.6, 4.5, 4.7, 3.3, 4.6, 3.9, 3.5,
print(3)
时,我在控制台中看到输出为3
,但当我尝试运行时,下面的代码会给我一个错误。它工作得非常完美,突然抛出了这些奇怪的错误
我尝试重新启动、重新安装和升级所有库,但没有任何效果
import numpy as np
versicolor_petal_length = np.array([4.7, 4.5, 4.9, 4., 4.6, 4.5, 4.7, 3.3, 4.6, 3.9, 3.5,
4.2, 4., 4.7, 3.6, 4.4, 4.5, 4.1, 4.5, 3.9, 4.8, 4.,
4.9, 4.7, 4.3, 4.4, 4.8, 5., 4.5, 3.5, 3.8, 3.7, 3.9,
5.1, 4.5, 4.5, 4.7, 4.4, 4.1, 4., 4.4, 4.6, 4., 3.3,
4.2, 4.2, 4.2, 4.3, 3., 4.1])
versicolor_petal_width = np.array([1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1., 1.3, 1.4, 1.,
1.5, 1., 1.4, 1.3, 1.4, 1.5, 1., 1.5, 1.1, 1.8, 1.3,
1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1., 1.1, 1., 1.2,
1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.,
1.3, 1.2, 1.3, 1.3, 1.1, 1.3])
def pearson_r(x, y):
"""Compute Pearson correlation coefficient between two arrays."""
# Compute correlation matrix: corr_mat
corr_mat = np.corrcoef(x, y)
# Return entry [0,1]
return corr_mat[0, 1]
# Compute Pearson correlation coefficient for I. versicolor: r
r = pearson_r(versicolor_petal_length, versicolor_petal_width)
# Print the result
print(r)
这是否回答了您的问题?我试过那个解决方案,它不起作用。对我来说很好。你能告诉我你的内存容量是多少吗,因为有时候内存会成为瓶颈。8GB内存,我的机器是Macbook 2017型号