I am Charmie

メモとログ

python

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…

pytorch

pytorchを使った方が良いかもしれないと思ったので,色々調査. Tensor 任意オーダーのtensorを定義する型 Tutorialではオーダーが1,2のtensor(つまり,ベクトルと行列)のみを例として扱っている NumPyのArray型と互換性を持つ Autograd Tensorのあらゆる計…

PyGTK for Python 3.5 installation on Ubuntu 16.04 with anaconda

see here conda install -c ska pygtk

Implementation: CycleGAN and Pix2pix

The implementation of CycleGAN and Pix2pix based on pytorch is published on github. Here's a todo procedure with anaconda. The CPU mode installation is under test right now... pytorch installation see the repository For a machine with GPU …

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…

upgrade/downgrade python version of anaconda

Same as python packages, we can use conda install to upgrade/downgrade python version as conda install python=..* To know the available version, just type conda search ppthon

install pre-built dlib for python

following this page, we can install dlib pre-built library for python on all platform. conda install -c conda-forge dlib When I tried, the library had a conflict with CGAL 4.7. I simply uninstalled CGAL and then successfully installed dlib…

Megaman: Scalable Manifold Learning in Python

megaman is a python module for scalable manifold learning. So far, anaconda does not provide its binary for windows.

install graphillion into anaconda

following the guidance, you should type conda install -c auto graphillion

Sympyまとめ (N-dim array)

Sympyのtensor用機能 We have two tensors $latex A \in \mathbb{R}^{I_1 \times \ldots \times I_N}$ and $latex B \in \mathbb{R}^{J_1 \times \ldots \times J_N}$. An element is specified by $latex A(i_1, \ldots, i_N)$, where $latex 1 \leq i_k \l…

Sympyまとめ (Matrices)

[code lang="python"] >>> Matrix([[1, -1], [3, 4], [0, 2]]) ⎡1 -1⎤ ⎢ ⎥ ⎢3 4 ⎥ ⎢ ⎥ ⎣0 2 ⎦ 列ベクトルを作るには,要素のリストを与える >>> Matrix([1, 2, 3]) ⎡1⎤ ⎢ ⎥ ⎢2⎥ ⎢ ⎥ ⎣3⎦ 行列とベクトルの掛け算 >>> M = Matrix([[1, 2, 3], [3, 2, 1]]) >>> …

SymPyまとめ (special functions)

functions for Combinatorial functions for Enumerations

SymPyまとめ (simplification)

From basic operations, 1.1. evalf() outputs numerical value(s). [code lang="python"] >>> expr = sqrt(8) >>> expr 2 * sqrt(2) >>> expr.evalf() 2.82842712474619 [/code] 1.2. lambdify acts like lambda function. [code lang="python"] >>> import…

Matplotlib animation with spyder

A solution enabling spyder to show matplotlib animation is to change the settings Tools > Preferences > IPython console > Graphics > Backend from "Inline" to "Automatic" and then push apply button.

keras installation on ubuntu 16.04 with CUDA and cuDNN

install CUDA download cuda-repo-ubuntu1604_8.0.44-1_amd64.deb from here sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb sudo apt-get update sudo apt-get cuda update path settings add the following lines at the end of ~/.bashrc and typ…

enable OpenCV-Python compilation with OpenCV 3.2.0

With default CMakeLists.txt, we cannot compile OpenCV-Python with OpenCV 3.2.0 because 1. add_subdirectory() for python2 do not work appropriately 2. add_subdirectory() for python3 do not work appropriately 3. CMakeLists.txt in the root di…

install python non-negative matrix factorization module nimfa on anaconda

conda install -c cdeepakroy nimfa

Leap Motion SDK for Anaconda on Windows

Let ANACONDA_ROOT_DIR denote the root directory of Anaconda, C:\Anaconda2 in my case. copy Leap.py to ANACONDA_ROOT_DIR\Lib copy Leap.dll, LeapPython.pyd, msvcp120.dll, msvcr120.dll to ANACONDA_ROOT_DIR\DLLs

PyQtGraph on Ubuntu

installed PyQtGraph on anaconda running on Ubuntu 14.04 conda install pyopengl conda install pyqtgraph

Leap Motion SDK on Linux

See the REAEME file. sudo dpkg --install Leap-*-x64.deb sudo cp ./LeapSDK/lib/x64/* /usr/lib/ sudo cp ./LeapSDK/include/* /usr/include/ For anaconda, sudo cp ./LeapSDK/lib/x64/* ANACONDA_ROOT_DIR/lib/python2.7/site-packages/

Python: tuple of size 1

We can make a tuple of size 1 as tuple_a = (a, )

OpenCV Python flags

OpenCV flags have a little bit different names when using with python. The name CV_FLAGNAME is set as cv2.FLAGNAME. For instance, CV_CALIB_CB_ADAPTIVE_THRESH is defined as cv2.CALIB_CB_ADAPTIVE_THRESH.

spyder crashes with pyqt

spyder installed in my Windows 10 PC failed to boot after update conda --all. The error cause is a kind of conflict between pyqt and pyside. A solution I found on the web is here and it worked on my case. The solution is re-install pyqt ve…

Anaconda: pydicom 1.0.0a on Windows 10

To install pydicom 1.0.0a to Anaconda on Windows 10, we should build the package by ourselves. git clone https://github.com/darcymason/pydicom.git cd pydicom python setup.py install Install with conda cloud installs the version 0.9.9. The …

Python: set

setsPython 2.3で追加され,2.6で撤廃された. 2.6以降は組み込み型のsetを使う. listやnumpy.arrayを使っても似たようなことができそうだけど,集合は集合ということでsetを使った方が良い. [code lang="python"] import random if name == "main": # def…

Python: コールバック関数

関数の引数として呼ぶ関数をコールバック関数と呼ぶ. C, C++と違い,Pythonのコールバック関数を使うのは非常に簡単ということが分かった. ひとまず,コールバック関数をarithmetic.pyに保存. [code lang="python"] arithmetic.py def add(a, b): return …

Set in Python

集合(Set)を扱うPythonのモジュールを調べたり試したり. setモジュール/ set module len(s): 集合sの要素数を返す x in s: xがsのメンバーに含まれていればTrueを返す x not in s: xがsのメンバーに含まれていればTrueを返す s.isdisjoint(t): sとtが共通…

Python module: shapely

Shapely is a python module for manipulation and analysis of planar geometric objects. Installation Execute a command from either of the followings: conda install -c scitools shapely pip install shapely 以下,ユーザマニュアルの要約をダラダ…

OpenCV 3.1.0 for Python2.7

PYTHON2_EXECUTABLE: /opt/anaconda/anaconda2/bin/python2.7 PYTHON2_INCLUDE_DIR: /opt/anaconda/anaconda2/include PYTHON2_INCLUDE_DIR2: PYTHON2_LIBRARY: /opt/anaconda/anaconda2/lib/libpython2.7.so PYTHON2_LIBRARY_DEBUG: PYTHON2_NUMPY_INCLUDE…