次のコードセグメントを実行すると、plt.imshow(X[0,:,:]) plt.show()
の最後の2行にエラーメッセージIllegal instruction (core dumped)
が生成され続けます。これの理由は何か分かりますか?numpyとmatplotlibを使用して生成されたイメージを表示するときに不正な命令(コアダンプ)メッセージ
import os
import numpy as np
import matplotlib.pyplot as plt
import pylab
from scipy.ndimage.filters import gaussian_filter
from scipy import ndimage
np.random.seed(1234)
pylab.rcParams['figure.figsize'] = (10.0, 8.0)
nx = 572
ny = 572
sigma = 10
plateau_min = -2
plateau_max = 2
r_min = 1
r_max = 200
def create_image_and_label(nx,ny):
x = np.int(np.random.rand(1)[0]*nx)
y = np.int(np.random.rand(1)[0]*ny)
image = np.ones((nx,ny))
label = np.ones((nx,ny))
image[x,y] = 0
image_distance = ndimage.morphology.distance_transform_edt(image)
r = np.random.rand(1)[0]*(r_max-r_min)+r_min
plateau = np.random.rand(1)[0]*(plateau_max-plateau_min)+plateau_min
label[image_distance <= r] = 0
label[image_distance > r] = 1
label = (1 - label)
image_distance[image_distance <= r] = 0
image_distance[image_distance > r] = 1
image_distance = (1 - image_distance)*plateau
image = image_distance + np.random.randn(nx,ny)/sigma
return image, label[92:nx-92,92:nx-92]
def create_batch(nx,ny,n_image):
X = np.zeros((n_image,nx,ny))
Y = np.zeros((n_image,nx-184,ny-184,2))
for i in range(n_image):
X[i,:,:],Y[i,:,:,1] = create_image_and_label(nx,ny)
Y[i,:,:,0] = 1-Y[i,:,:,1]
return X,Y
X,Y = create_batch(nx,ny,1)
print(X.shape)
plt.imshow(X[0,:,:])
plt.show()
これはmatplotlibのバグのようです。メーリングリスト(http://matplotlib.org/faq/troubleshooting_faq.html)にレポートを提出することを検討しましたか? – nneonneo
これは、通常、誰かがファイルにテキストエディタを使用した場合、または間違ったアーキテクチャである場合、 "壊れた"バイナリ.soファイルによって引き起こされる可能性があります。 – cdarke
この問題に関連する可能性があります:https://bbs.archlinux.org/viewtopic.php?id=215589同じエラーが発生したときの解決法(atlas-lapack-baseをアンインストールしてlapackをインストールする)が私にとってうまくいった。 – Mark