tensorflowをバックエンドにkerasをインストールし、試しに以下のコード(https://qiita.com/sasayabaku/items/64a01363bcd5c44feb0b)を実行しましたが、TypeError: reduce_sum() got an unexpected keyword argument 'axis'
というエラーがでてしまいました。バージョンの問題かと思ってkerasを最新バージョンにアップグレードしましたがやはりうまく動きませんでした。他のプログラムも試しましたがうまくいきませんでした。
# encoding: utf-8 from keras.datasets import mnist from keras.models import Sequential from keras.layers.core import Dense, Activation from keras.utils import np_utils # kerasのMNISTデータの取得 (X_train, y_train), (X_test, y_test) = mnist.load_data() # 配列の整形と,色の範囲を0-255 -> 0-1に変換 X_train = X_train.reshape(60000, 784) / 255 X_test = X_test.reshape(10000, 784) / 255 # 正解ラベルをダミー変数に変換 y_train = np_utils.to_categorical(y_train) y_test = np_utils.to_categorical(y_test) # ネットワークの定義 model = Sequential([ Dense(512, input_shape=(784,)), Activation('sigmoid'), Dense(10), Activation('softmax') ]) # 損失関数,最適化アルゴリズムなどの設定 + モデルのコンパイルを行う model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy']) # 学習処理の実行 -> 変数histに進捗の情報が格納される # validation_split=0.1 ---> 0.1(10%)の訓練データが交差検証に使われる hist = model.fit(X_train, y_train, batch_size=200, verbose=1, epochs=3, validation_split=0.1) # 予測 score = model.evaluate(X_test, y_test, verbose=1) print("") print('test accuracy : ', score[1])
バージョンは以下の通りです。
~$ python -m pip freeze appdirs==1.4.3 bleach==1.5.0 cycler==0.10.0 decorator==4.0.11 entrypoints==0.2.2 html5lib==0.999 ipykernel==4.6.1 ipython==6.0.0 ipython-genutils==0.2.0 Jinja2==2.9.6 jsonschema==2.6.0 jupyter-client==5.0.1 jupyter-core==4.3.0 Keras==2.0.8 MarkupSafe==0.23 matplotlib==2.0.0 mistune==0.7.4 nbconvert==5.1.1 nbformat==4.3.0 notebook==5.0.0 numpy==1.13.1 olefile==0.44 packaging==16.8 pandocfilters==1.4.1 pexpect==4.2.1 pickleshare==0.7.4 Pillow==4.2.1 prompt-toolkit==1.0.14 protobuf==3.2.0 ptyprocess==0.5.1 Pygments==2.2.0 pyparsing==2.2.0 python-dateutil==2.6.0 pytz==2017.2 PyYAML==3.12 pyzmq==16.0.2 scikit-learn==0.19.0 scipy==0.19.1 simplegeneric==0.8.1 six==1.10.0 tensorflow==1.0.1 terminado==0.6 testpath==0.3 Theano==0.9.0 tornado==4.5.1 traitlets==4.3.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/10 05:39