繁体   English   中英

运行此神经网络代码时,Jupyter kernel 死机

[英]Jupyter kernel dies while running this neural networks code


import numpy as np

import cv2

import os

import matplotlib.pyplot as plt

from tensorflow.keras.preprocessing.image import ImageDataGenerator

from tensorflow.keras.preprocessing import image

from tensorflow.keras.optimizers import RMSprop

img = image.load_img("image_location_here")

train = ImageDataGenerator(rescale=1/255)

validation = ImageDataGenerator(rescale=1/255)

train_dataset = train.flow_from_directory('image_location_here', target_size = (50,50),  batch_size = 3,
  class_mode = 'binary')

validation_dataset = train.flow_from_directory('image_location_here', target_size = (50,50),batch_size = 3,
class_mode = 'binary')     
                         
train_dataset.class_indices

train_dataset.classes

model = tf.keras.models.Sequential

tf.keras.layers.Conv2D(16,(3,3),activation = 'relu', input_shape = (50,50,3))` `tf.keras.layers.MaxPool2D(2,2)

tf.keras.layers.Conv2D(32,(3,3),activation = 'relu'),tf.keras.layers.MaxPool2D(2,2)

tf.keras.layers.Conv2D(64,(3,3),activation = 'relu')

tf.keras.layers.MaxPool2D(2,2)

tf.keras.layers.Flatten()

tf.keras.layers.Dense(128,activation = 'relu')

tf.keras.layers.Dense(1, activation = 'sigmoid')

上面的代码运行良好,但是当我运行下面给出的行时,kernel 死了。

model().compile(loss = 'binary_crossentropy', optimizer = 'adam', metrices = ['accuracy'])

我已将 anaconda 更新到最新版本,重新启动几次后 kernel 仍死于该特定行。

抱歉,线条编辑不当

我最近有一个类似的问题。 问题是由 CUDA/cudNN 引起的,可能是因为您使用的版本与 Tensorflow 不兼容。有两种解决方案:

  1. 卸载CUDA,重新安装Tensorflow库
  2. 卸载 CUDA 并设置兼容的 CUDA/cudNN 版本(检查https://tensorflow.org/install/source_windows以获得 tensorflow 版本所需的版本)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM