Как я могу исправить файл, когда ядро ​​умирает?Python

Программы на Python
Ответить
Anonymous
 Как я могу исправить файл, когда ядро ​​умирает?

Сообщение Anonymous »

Я новичок в тензорном потоке и керасе. Когда я пытаюсь объединить matplotlib с keras и тензорным потоком, мое ядро ​​умирает.
Это код, который у меня есть:

Код: Выделить всё

import numpy as np
import os
np.random.seed(42)

import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rc('axes', labelsize=14)
mpl.rc('xtick', labelsize=12)
mpl.rc('ytick', labelsize=12)

def save_fig(fig_id, tight_layout=True, fig_extension="png", resolution=300):
print("Saving figure", fig_id)
if tight_layout:
plt.tight_layout()
plt.savefig(fig_id, format=fig_extension, dpi=resolution)

import tensorflow as tf
from tensorflow import keras

(X_train_full, y_train_full), (X_test, y_test) =     keras.datasets.mnist.load_data()

X_valid, X_train = X_train_full[:5000] / 255.,     X_train_full[5000:] / 255.
y_valid, y_train = y_train_full[:5000], y_train_full[5000:]
X_test = X_test / 255.

print(y_train)
print(X_valid.shape)
print(X_test.shape)

# Multinomial logistic regression
np.random.seed(42)
tf.random.set_seed(42)

model = keras.models.Sequential([
keras.layers.Flatten(input_shape=[28, 28]),
keras.layers.Dense(10, activation="softmax")
])

model.summary()

model.compile(loss="sparse_categorical_crossentropy",     optimizer="sgd",
metrics=["accuracy"])

history = model.fit(X_train, y_train, epochs=3,
validation_data=(X_valid, y_valid))

import pandas as pd

pd.DataFrame(history.history).plot(figsize=(8, 5))
plt.grid(True)
plt.gca().set_ylim(0, 1)
save_fig("learning_curves_plot")
plt.show()
Моя проблема начинается, когда я запускаю последние 4 строки кода, где я хочу отобразить результаты. Ядро останавливается и умирает автоматически. Я получаю следующее сообщение:

Код: Выделить всё

2023-05-07 11:16:49.401786: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-05-07 11:16:49.403200: I tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
OMP: Error #15: Initializing `libiomp5md.dll`, but found libiomp5 already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable `KMP_DUPLICATE_LIB_OK=TRUE` to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results.  For more information, please see `http://www.intel.com/software/products/support/.`

Fatal Python error: Aborted
Основная тема:

Код: Выделить всё

Current thread 0x000036b0 (most recent call first):
File "", line 180 in dot
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\transforms.py", line 2441 in get_affine
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\transforms.py", line 2415 in transform_affine
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\transforms.py", line 1490 in transform
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\transforms.py", line 479 in transformed
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\axis.py", line 2475 in get_tick_space
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\ticker.py", line 2083 in _raw_ticks
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\ticker.py", line 2144 in tick_values
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\ticker.py", line 2136 in __call__
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\axis.py", line 1484 in get_majorticklocs
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\axis.py", line 1262 in _update_ticks
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\matplotlib\axis.py", line 1413 in get_majorticklabels
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 741 in _apply_axis_properties
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 652 in _post_plot_logic_common
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 454 in generate
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\pandas\plotting\_matplotlib\__init__.py", line 71 in plot
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\pandas\plotting\_core.py", line 975 in __call__
File "c:\users\frang\.spyder-py3\tutor\spyder\f06_mnist.py", line 94 in 
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\spyder_kernels\py3compat.py", line 356 in compat_exec
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 469 in exec_code
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 611 in _exec_file
File "C:\Users\frang\anaconda3\envs\tf\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 524 in runfile
File "C:\Users\frang\AppData\Local\Temp\ipykernel_2248\1988908460.py", line 1 in 

Restarting kernel...
Я был бы очень признателен за помощь в устранении этой ошибки, поскольку она случается и с другими файлами. Проблема с установкой пакетов? Что мне делать?
Спасибо всем за потраченное время и усилия

Подробнее здесь: https://stackoverflow.com/questions/761 ... ernel-dies
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»