Question

KERNEL dies so frequently while running .ipynb using Jupyter Notebook.

from keras.preprocessing import image
from tqdm import tqdm

def path_to_tensor(img_path): # loads RGB image as PIL.Image.Image type img = image.load_img(img_path, target_size=(224, 224)) # convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3) x = image.img_to_array(img) # convert 3D tensor to 4D tensor with shape (1, 224, 224, 3) and return 4D tensor return np.expand_dims(x, axis=0)

def paths_to_tensor(img_paths): list_of_tensors = [path_to_tensor(img_path) for img_path in tqdm(img_paths)] return np.vstack(list_of_tensors)```

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

pre-process the data for Keras

train_tensors = paths_to_tensor(train_files).astype(‘float32’)/255 valid_tensors = paths_to_tensor(valid_files).astype(‘float32’)/255 test_tensors = paths_to_tensor(test_files).astype(‘float32’)/255

```The error mesg. - "Kernel Restarting

The kernel appears to have died. It will restart automatically."

From Jupyter notebook log please find below the snapshot and see how frequently the kernel is getting stopped in between - 

**[I 06:53:09.792 NotebookApp] Kernel started: 1a6cc3fd-6f08-493e-9276-b6c79b186ec0**
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
[I 06:55:10.347 NotebookApp] Saving file at /dog_app.ipynb
**[I 06:55:42.814 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 06:57:10.327 NotebookApp] Saving file at /dog_app.ipynb
[I 06:59:12.226 NotebookApp] Saving file at /dog_app.ipynb
**[I 06:59:57.833 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 07:01:10.341 NotebookApp] Saving file at /dog_app.ipynb
**[I 07:02:33.857 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**

[I 07:03:10.331 NotebookApp] Saving file at /dog_app.ipynb
[I 07:05:10.009 NotebookApp] Saving file at /dog_app.ipynb
**[I 07:06:03.874 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 1a6cc3fd-6f08-493e-9276-b6c79b186ec0 restarted**


Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer