I am Charmie

メモとログ

keras

Keras: a callback function to save loss on each batch

Inspired by this stackoverflow answer and keras.callbacks.CSVLogger, I implemented a callback function to save loss on each batch. [code lang='python'] class LossHistory(Callback): def __init__(self, filename, separator=',', append=False):…

libcudnn related error after Ubuntu apt update

I got "ImportError of libcudnn.so.6" after Ubuntu apt update although I have no idea how apt update causes the error. The solution is re-install cuDNN. Library files of cuDNN disappeared from a directory where is one of LD_LIBRARY_PATH. So…

tensorflow-gpu 1.4.0 + keras 2.1.1 on Ubuntu 16.04

Tensorflow 1.4.0 binary with CUDA 8 and cuDNN 6 Tensorflow 1.5.0 binary will be with CUDA 9 and cuDNN 7 The following procedure assumes that you use anaconda for python package manager. prepare for driver install Delete installed drivers b…

Keras install error with Anaconda 5.0.0 for Python 3.5.4

"pip install keras" returns the following TypeError. The solution found at StackOverflow says to 1. install html5lib by conda install --force html5lib 2. install keras by pip install keras

Keras: MNIST classification

Keras implementation for MNIST classification with batch normalization and leaky ReLU. [code lang="python"] import numpy as np import time import pandas as pd import matplotlib.pyplot as plt from keras.datasets import mnist from keras.mode…

Keras: error at the beginning of fit with Dropout

When Keras' model contains Dropout component in it, we must tell the model whether we are training or test mode because the network behaves differently. The solution is mentioned in github issue and Keras docs. [code lang="python"] from ke…

Keras: plot_model returns pydot and graphviz related error on Windows

plot_model of Keras installed on Windows may return pydot and graphviz related error like "Graphviz's executables are not found'. The error cause is that the computer does not know the path of Graphviz's executable exactly mentioned as the…

find a layer by name in Keras

[code lang="python"] for layer in model.layers layer_name = layer.get_config()['name'] print(layer_name) if layer_name is 'foo': print('foo') else: print('bar') [/code]

customize a model in Keras

Here's a note to customize a pre-defined model in Keras. This official information and stackoverflow post gave me how to do it. A Model is a list of layers (or layer instances) such as [code lang="python"] model = Sequential([ Dense(32, in…

Keras: multiple inputs & outputs

[code lang="python"] from keras.models import Model from keras.layers import Input, Dense input_1 = Input(..., name='input_1') x = Dense(...)(input_1) x = Dense(...)(x) ... output_1 = Dense(dim_output_1, ..., name='output_1') input_2 = Inp…

install keras + tensorflow (GPU) to Windows using anaconda

Install Tensorflow and Keras Run Anaconda Prompt Install Tensorflow # pip install tensorflow-gpu Install Keras # pip install keras (Optional) Change Keras' backend from Theano to TensorFlow This step is optional if Keras uses Theano as its…

pydot error on Keras

you might have an error of pydot when you use keras.utils.visualize_util.plot. The error says that "Couldn't import dot_parser, loading of dot files will not be possible." The error is caused by incompatibility between pydot and pyparsing.…