我正在尝试研究Keras库,并且尝试从 github/fchollet/keras/tree/master/examples
I am trying to study Keras library and I tried to run this example from github/fchollet/keras/tree/master/examples
'''Trains a simple deep NN on the MNIST dataset. Gets to 98.40% test accuracy after 20 epochs (there is *a lot* of margin for parameter tuning). 2 seconds per epoch on a K520 GPU. ''' from __future__ import print_function import numpy as np np.random.seed(1337) # for reproducibility from keras.datasets import mnist from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation from keras.optimizers import SGD, Adam, RMSprop from keras.utils import np_utils batch_size = 128 nb_classes = 10 nb_epoch = 20 # the data, shuffled and split between train and test sets (X_train, y_train), (X_test, y_test) = mnist.load_data() X_train = X_train.reshape(60000, 784) X_test = X_test.reshape(10000, 784) X_train = X_train.astype('float32') X_test = X_test.astype('float32') X_train /= 255 X_test /= 255 print(X_train.shape[0], 'train samples') print(X_test.shape[0], 'test samples') # convert class vectors to binary class matrices Y_train = np_utils.to_categorical(y_train, nb_classes) Y_test = np_utils.to_categorical(y_test, nb_classes) model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(10)) model.add(Activation('softmax')) model.summary() modelpile(loss='categorical_crossentropy', optimizer=RMSprop(), metrics=['accuracy']) history = model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch, verbose=1, validation_data=(X_test, Y_test)) score = model.evaluate(X_test, Y_test, verbose=0) print('Test score:', score[0]) print('Test accuracy:', score[1])然后我得到了这个错误 docs.google/document/d /1bo24LXbfK-NzqOBmblqM5KL91P3L3FMD1Wzq-Z5VMq0/edit?usp = sharing
and than I got this error docs.google/document/d/1bo24LXbfK-NzqOBmblqM5KL91P3L3FMD1Wzq-Z5VMq0/edit?usp=sharing
我正在使用最新版本的amd gpu,python 3.5和keras运行Windows 10 64bit
I'm running windows 10 64bit with amd gpu, python 3.5 and keras in the latest version
推荐答案不幸的是,Keras和Theano在Windows上的Python 3上不能很好地工作.您遇到的问题与以下事实有关:您必须将libpython库添加到C ++ Windows编译器,并将其与Python安装连接,而在安装Python 3.5的情况下,这可能会非常困难.我建议您将其安装在Python 2上.在这里,您有确切的操作说明:
Unfortunately, Keras and Theano don't work well with Python 3 on Windows. The problem you have is connected with the fact that you have to add libpython libraries to your C++ Windows Compiler and connect it with your Python installation which could be quite harsh when you have Python 3.5 installed. I would rather advice you to install it on Python 2. Here you have an exact instruction how to do it :
如何进行在Windows的Anaconda Python中安装Keras和Theano吗?
更多推荐
keras示例不起作用
发布评论