Code Monkey home page Code Monkey logo

deep-learning-with-keras-ja's Introduction

直感 Deep Learning


表紙


本リポジトリはオライリー・ジャパン発行書籍『直感 Deep Learning』(原書名『Deep Learning with Keras』)のサポートサイトです。

サンプルコード

ファイル構成

フォルダ名 説明
ch01 1章で使用するソースコードとライブラリ導入に必要なrequirements.txt
ch02 2章で使用するソースコードとライブラリ導入に必要なrequirements.txt
... ...
ch08 8章で使用するソースコードとライブラリ導入に必要なrequirements.txt

サンプルコードの解説は本書籍をご覧ください。

仮想環境の準備

環境構築の方法は読者に任せていますが、一般的には仮想環境を構築する方法を推奨されるのでその方法を記述しておきます。

pyenvvirtualenvの導入をします。

linux

apt-get install pyenv
apt-get install virtualenv

Mac

brew install pyenv
brew install virtualenv

pyenvvirtualenvを用いて仮想環境を構築します。

pyenv install 3.6.0
pyenv rehash
pyenv local 3.6.0
virtualenv -p ~/.pyenv/versions/3.6.0/bin/python3.6 my_env
source my_env/bin/activate

Windows

Anacondaを導入して下さい。

使用方法

サンプルを実行する前に、必要なライブラリをインストールする必要があります。

$ pip install -r requirements.txt

CPU用のrequirements.txtとGPU用のrequirements_gpu.txtを章ごとに用意してあります。

巻末の付録Aで、GPUを考慮した開発環境の構築について補足していますので参考にしてください。

各章のフォルダへ移動して、Pythonコマンドを実行します。書籍にどのpythonコードを動作させているか明記しています。

下記は一例です。

cd ch03
python cifar10_deep_with_aug.py

実行環境

日本語版で検証に使用した各ソフトウェアのバージョン、およびハードウェアは次のとおりです。

ソフトウェア

  • Pycharm-community-2017.1
  • Python 3.6.0(10章ではDocker環境での簡易的な確認のため3.5.2)
  • TensorFlow 1.8.0
  • Keras 2.1.6(4章では他のライブラリとの関係があるため2.1.2)
  • h5py 2.7.1
  • numpy 1.14.0
  • scipy 1.0.0
  • quiver-engine 0.1.4.1.4
  • matplotlib 2.1.1
  • picklable_itertools 0.1.1以上
  • sacred 0.6.10以上
  • tqdm 4.8.4以上
  • q 2.6以上
  • gensim 3.2.0
  • nltk 3.2.5
  • scikit-learn 0.19.1
  • pandas 0.22.0
  • Pillow 4.3.0
  • gym 0.10.5
  • pygame 1.9.3
  • html5lib 0.9999999
  • keras-adversarial 0.0.3
  • PyYAML 3.12
  • requests 2.14.2
GPUを使用する場合
  • tensorflow-gpu 1.8.0
  • cuda 9.0
  • cuDNN 7.0.5
Macで使用する場合の注意点

matplotlibを標準設定のまま使用すると下記のようなエラーが発生します。これはMacで設定されている標準の画像レンダリングAPIがmatplotlibで使用するものと異なるためです。

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

matplotlibを使用する前に下記のように画像レンダリングAPIを設定して使用してください。

import matplotlib as mpl
mpl.use('TkAgg')

動作確認済みハードウェア

  • Ubuntu 16.04 LTS(GPU:GeForce GTX 1080)
  • 64ビットアーキテクチャ
  • Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
  • 16GBのRAM
  • ハードディスクの空き容量は少なくとも10GB

正誤表

下記の誤りがありました。お詫びして訂正いたします。

本ページに掲載されていない誤植など間違いを見つけた方は、[email protected]までお知らせください。

第2刷まで

■1章 P.27 10行目

シグモイド関数は連続関数なので、微分可能です。

シグモイドは連続関数であり、微分可能です。

第1刷

■1章 P.22 1行目

from keras.layersimport Dense, Dropout, Activation

from keras.layers import Dense, Dropout, Activation

■2章 P.67 脚注

前:package_data=’quiver_engine’: ’quiverboard/dist/*’,
後:package_data=’quiver_engine’: [’quiverboard/dist/*’],

前:package_data={'quiver_engine': 'quiverboard/dist/*'},
後:package_data={'quiver_engine': ['quiverboard/dist/*']},

■3章 P.96 8~13行目

from pathlib import Path
import pathlib
import numpy as np
from PIL import Image
from keras.models import load_model

model_path = "logdir/model_file.hdf5"

from pathlib import Path
import numpy as np
from PIL import Image
from keras.models import load_model

model_path = "logdir_cifar10_deep_with_aug/model_file.hdf5"

■4章 P.112 1行目

DCGGAN生成モデルは、以下のKerasコードで実装できます。

DCGAN生成モデルは、以下のKerasコードで実装できます。

■6章 P.177 10行目

今回の場合、語彙数は42です。

今回の場合、語彙数は60です。

■6章 P.179 35~36行目

        for i, ch in enumerate(test_chars):
            Xtest[0, i, char2index[ch]] = 1

        for j, ch in enumerate(test_chars):
            Xtest[0, j, char2index[ch]] = 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.