Произошла ошибка при запуске ядра 2 - PullRequest
0 голосов
/ 07 мая 2018

Я могу запустить этот код, и все в порядке:

from keras.datasets import mnist
def plot_history(net_history):
history = net_history.history
import matplotlib.pyplot as plt
losses = history['loss']
val_losses = history['val_loss']
accuracies = history['acc']
val_accuracies = history['val_acc']

plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.plot(losses)
plt.plot(val_losses)
plt.legend(['loss', 'val_loss'])

plt.figure()
plt.xlabel('Epochs')
plt.ylabel('Accuracy')
plt.plot(accuracies)
plt.plot(val_accuracies)
plt.legend(['acc', 'val_acc'])

# Load data
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

# Data attributes
X_train = train_images.reshape(60000, 784)
X_test = test_images.reshape(10000, 784)

X_train = X_train.astype('float32')
X_test = X_test.astype('float32')

X_train /= 255
X_test /= 255

from keras.utils import np_utils
Y_train = np_utils.to_categorical(train_labels)
Y_test = np_utils.to_categorical(test_labels)

#==================================================
# Creating our model
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import SGD
from keras.losses import categorical_crossentropy

myModel = Sequential()
myModel.add(Dense(500, activation='relu', input_shape=(784,)))
myModel.add(Dropout(20))
myModel.add(Dense(100, activation='relu'))
myModel.add(Dropout(20))
myModel.add(Dense(10, activation='softmax'))

myModel.summary()
myModel.compile(optimizer=SGD(lr=0.001), loss=categorical_crossentropy, 
metrics=['accuracy'])

#==================================================
# Train our model
network_history = myModel.fit(X_train, Y_train, batch_size=128, epochs=20, 
validation_split=0.2)
plot_history(network_history)

но когда я не могу запустить code_2:

#code_2
from keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

# Data attributes    
X_train = train_images.reshape(60000, 28 , 28 ,1)
X_test = test_images.reshape(10000, 28, 28, 1)

X_train = X_train.astype('float32')
X_test = X_test.astype('float32')

X_train /= 255
X_test /= 255
from keras.utils import np_utils
Y_train = np_utils.to_categorical(train_labels)
Y_test = np_utils.to_categorical(test_labels)
# Creating our model
from keras.models import Model
from keras.layers import Conv2D, MaxPool2D, Input, Flatten, Dense
import keras
myInput = Input(shape=(28,28,1))
conv1 = Conv2D(16, (3,3), activation = 'relu', padding = 'same')(myInput)
pool1= MaxPool2D(pool_size = 2)(conv1)
conv2 = Conv2D(32, (3,3), activation = 'relu', padding = 'same')(pool1)
pool2= MaxPool2D(pool_size = 2)(conv2)

flat = Flatten()(pool2)

out_layer = Dense(10, activation = 'softmax')(flat)

myModel = Model(myInput, out_layer)

myModel.summary()
myModel.compile(optimizer = keras.optimizers.Adam(), 
loss=keras.losses.categorical_crossentropy, metrics=['accuracy'])

#==================================================
# Train our model
network_history = myModel.fit(X_train, Y_train, batch_size=128, epochs=2, 
validation_split=0.2)

Erorr

Произошла ошибка при запуске ядра 2018–15: 26: 08.943071: I T: \ src \ github \ tenorflow \ tenorflow \ core \ common_runtime \ gpu \ gpu_device.cc: 1344] Найдено устройство 0 со свойствами: название: GeForce GT 740M, майор: 3 минор: 5, MemoryClockRate (ГГц): 1,0325 pciBusID: 0000: 01: 00.0 общая память: 2,00 гигабайт свободная память: 1,91 гигабайт 2018–15: 26: 08.943124: I T: \ src \ github \ tenorflow \ tenorsflow \ core \ common_runtime \ gpu \ gpu_device.cc: 1423] Добавление видимых устройств GPU: 0 2018–15: 26: 09.399518: I T: \ src \ github \ tenorflow \ tenorflow \ core \ common_runtime \ gpu \ gpu_device.cc: 911] Соединение устройств StreamExecutor с прочностью 1 реберной матрицы: 2018–15: 26: 09.399535: I T: \ src \ github \ensorflow \ tenorsflow \ core \ common_runtime \ gpu \ gpu_device.cc: 917] 0 2018–15: 26: 09.399540: I T: \ src \ github \ensorflow \ tenorsflow \ core \ common_runtime \ gpu \ gpu_device.cc: 930] 0: N 2018–15: 26: 09.399664: ИТ: \ src \ github \ tenorflow \ tenorflow \ core \ common_runtime \ gpu \ gpu_device.cc: 1041] Создано устройство TensorFlow (/ job: localhost / replica: 0 / task: 0 / device) : GPU: 0 с 1700 МБ памяти) -> физический GPU (устройство: 0, имя: GeForce GT 740M, идентификатор шины pci: 0000: 01: 00.0, вычислительные возможности: 3,5)

* Зависимости 1016 *

IPython> = 4.0: 6.2.1 (ОК)

cython> = 0,21: 0,27,3 (ОК)

джедай> = 0,9,0: 0,11,1 (ОК)

nbconvert> = 4.0: 5.3.1 (OK)

numpy> = 1,7: 1,14,2 (ОК)

панд> = 0,13,1: 0,22,0 (ОК)

pycodestyle> = 2.3: 2.3.1 (OK)

pyflakes> = 0.6.0: 1.6.0 (OK)

pygments> = 2,0: 2,2,0 (ОК)

pylint> = 0,25: 1,8,2 (ОК)

qtconsole> = 4.2.0: 4.3.1 (OK)

веревка> = 0,9,4: 0,10,7 (ОК)

сфинкс> = 0,6,6: 1,6,6 (ОК)

sympy> = 0.7.3: 1.1.1 (ОК)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...