Skip to main content

Posts

Showing posts from 2019

Anaconda Prompt and Sublime Text - Windows (Add to right click)

Source:  https://gist.github.com/jiewpeng/8ba446acf329b1801bf91db767d179ea Open Regedit. Win + R > regedit.exe > Enter. Go to: Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\ Add a key named AnacondaPrompt and set its value (Default) to "Anaconda Prompt Here" (or anything you'd like it to appear as in the right click context menu) Add a key under this key, called command, and set its value to: cmd.exe /K C:\Users\rb\Anaconda3\Scripts\activate.bat (may have to change the activate.bat file to whereever Anaconda is installed) No need to restart. To setup conda env to another dir: https://stackoverflow.com/questions/67610133 conda config --show conda config --add pkgs_dirs D:/.conda/pkgs conda config --add envs_dirs D:/.conda/envs conda config --remove envs_dirs  C:/Users/rb/.conda/envs conda config --remove envs_dirs  C:\Users\rb\AppData\Local\conda\conda\envs Sublime : Create a new file called foo.reg, paste the following text & execute it. Wind

Caffe : Softmax with Loss

Let us assume 2x2 image, 3 channels (labels possibilities) and 2 batch data. Then the predicted scores (logits) is given by: Assume 2x2 array is arranged in a single row. For N = 1 (of batch 2): [       9       2       5       8       ]       Each row is a class [       7       8       4       6       ]       Each column is score of scores of every class for a pixel [       8       4       6       7       ] For N = 2 (of batch 2): [       7       3       0       3       ] [       4       6       1       1       ] [       2       4       4       2       ] If we convert it to softmax scores (Caffe's Softmax does the same) say a column is: [   x     y     z   ] Then softmax score (which is calculated for every row/class/channel) is: [   e^x / ( e^x + e^y + e^z )     e^y / ( e^x + e^y + e^z )     e^z / ( e^x + e^y + e^z )   ] So softmax output will be: [   0.6652409   0.00242826  0.24472848  0.6652409   ] [   0.09003057  0.9796292   0.09003057  0.09003057  ]

Uninstalling CUDA 10.0 cuDNN 7.4.2 on Ubuntu 18.04 and Install CUDA 8.0 cuDNN 5.1

https://davidstutz.de/upgrading-cuda-and-installing-cudnn-for-caffe-and-tensorflow/ Check Ubuntu Version: lsb_release -a Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic If NVIDIA Driver is not installed: cd ~/Downloads sudo sh ./NVIDIA-Linux-x86_64-410.104.run register the kernel module sources with dkms - no 32 bit - no X config - yes Check CUDA version: nvcc --version Check cuDNN version: whereis cudnn.h cudnn: /usr/include/cudnn.h cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2 #define CUDNN_MAJOR 7 #define CUDNN_MINOR 4 #define CUDNN_PATCHLEVEL 2 -- #define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL) #include "driver_types.h" which means the version is 7.4.2. Uninstalling: Find the CUDA dir using: which nvcc Mine was: rb@rbhost:~$ which nvcc /usr/local/cuda-10.0/bin/nvcc To uninstall the CUDA Toolkit, run the uninstall script in `/usr/local/cuda-10.0/bin`

Install Caffe with GPU

The instruction are for: Caffe3D : Ubuntu, Caffe (2D) : Windows. The Caffe3D author did it in python 2.7, Ubuntu 14.04, CUDNN 5.1, CUDA 8.0 Read the errors at the end before you continue. And always make the Makefile.config yourself don't just copy paste. check for the folders carefully. Install Caffe 3D: Download  https://lmb.informatik.uni-freiburg.de/resources/opensource/caffe_unet_3D_v1.0.tar.gz Extract. Open README: git clone https://github.com/BVLC/caffe.git cd caffe git checkout 8c66fa5f3c04e -b unet_patch git cherry-pick 458928a # typo in installation.md git cherry-pick b43c8e4  # CuDNN 5 support git apply ../caffe_unet_3D_v1.0.patch # apply patch git add . git commit -m"U-Net 3D merged to BVLC/caffe 8c66fa5f3c04e" Then open: https://github.com/tbuikr/3D_DenseSeg Edit different files as mentioned there. Now need to compile for linux now: https://github.com/adeelz92/Install-Caffe-on-Ubuntu-16.04-Python-3 Error: libcudnn.so.5 is not a symbolic

Lecture 10 - Recurrent Neural Networks

Incomplete - Need to study more Batch Normalization is important to train deep nns. VGG 16 and 19 were developed before BN. So they trained 11 layer first added few layers trained again and so on. Inception used auxillary losses to train, not necessary but to propagate loss into first layers. Residual Nets: 1 important property, if the weights of residual network is zero, then it behaves as identity transformation, so that network can choose what is not required. Easy for the model to learn to not to use the layers it doesn't need. L2 regularization - making the weights to zero. 2 Gradient flow in backward pass is easy, so deeper nets can be designed. DenseNet and FractalNet - Study! Recurrent Neural Network   - Variable Size Data   x -------> [ RNN ] --------> y   Everytime x is inputted, RNN's hidden state will be updated, here's the difference: the internal hidden state will be fed back to the model on next input and so on. So input -> update

Cross Entropy Squared Error KL-Divergence

Cross Entropy Vs. Squared Error | KL-Divergence Generative Adversarial Network Generative model is about finding the underlying distribution or model from which the samples of images/data are supposed to come from. Say we have a million images of cats, so we can assume, all the images come from one distribution, Pcat So a sample from Pcat is an image of cat. So we want: to model Pcat. So we model the data / find the model of the data. Model = Distribution. [yt: hQv8FNaJHEA] Explicit model: Learns the actual parameter of the distribution. X_1 = P (X) --> Finding P Implicit model: Don't bother to learn the distribution of the data, instead focus on the stochastic [random] procedure that directly generate the data - on some input. X_1 = F_W(Z), Z = Latent space/input, W = Learned weights GAN are implicit models. Overall View: minG maxD { x~Pdata(X) E[ logD(X) ] + z~Pz(Z) E[ log ( 1 - D(G(Z)) )] X is a real data, Z is the noise, and G(Z) is

Popular CNN Architectures

[Source: https://adeshpande3.github.io/adeshpande3.github.io/The-9-Deep-Learning-Papers-You-Need-To-Know-About.html] output_size = ( I + P_left + P_right - D*(F-1) -1) / S + 1 I = Input Size, F = Filter Size, D = Dilation, S = Stride, P = Padding Number of Filters = No. of Input Channels x No. of Output Channels. No. of Params = Filter Size (F x F) * No. of Filters AlexNet [2012] - The pioneering paper.     - IP = 227 x 227 x 3     - First use of ReLU     - Used Norm Layers (not common anymore)     - Heavy Data Augmentation - Flipping, Jittering, Cropping, Color Normalization, etc     - Dropout = 0.5     - Batch Size = 128     - SGD Momentum = 0.9     - Learning rate 1e-2 reduced by 10 manually when val accuracy plateaus     - L2 weight decay 5e-4     - 7 CNN ensemble: 18.2% -> 15.4% Training Multiple Models and Averaging them together. ZF Net [2013] - Slight modification on AlexNet - but explains convolutional networks very well - so far we believed convnets ar