🙋♂️ INFO: If you have fixes/suggestions to for this doc, please comment below.
🌟 STAR: This doc if you found this document helpful.
| from __future__ import print_function, absolute_import | |
| __all__ = ['accuracy'] | |
| def accuracy(output, target, topk=(1,)): | |
| """Computes the precision@k for the specified values of k""" | |
| maxk = max(topk) | |
| batch_size = target.size(0) | |
| _, pred = output.topk(maxk, 1, True, True) |
| #!/bin/bash | |
| # | |
| # script to extract ImageNet dataset | |
| # ILSVRC2012_img_train.tar (about 138 GB) | |
| # ILSVRC2012_img_val.tar (about 6.3 GB) | |
| # make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory | |
| # | |
| # https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md | |
| # | |
| # train/ |
| #!/bin/bash | |
| wget https://upload.wikimedia.org/wikipedia/en/9/94/Snipping_Tool_10_Icon.png ~/Pictures/snipping.png | |
| cd ~/.local/share/applications/ | |
| echo "[Desktop Entry]" > snipping-tools.desktop | |
| echo "Version=1.0" >> snipping-tools.desktop | |
| echo "Name=Snipping Tools" >> snipping-tools.desktop | |
| echo "Comment=A shortcut like Window Snipping Tools" >> snipping-tools.desktop | |
| echo "Exec=/usr/bin/gnome-screenshot -a -i" >> snipping-tools.desktop |
| """ | |
| Create train, valid, test iterators for CIFAR-10 [1]. | |
| Easily extended to MNIST, CIFAR-100 and Imagenet. | |
| [1]: https://discuss.pytorch.org/t/feedback-on-pytorch-for-kaggle-competitions/2252/4 | |
| """ | |
| import torch | |
| import numpy as np |
| # Create a simple TF Graph | |
| # By Omid Alemi - Jan 2017 | |
| # Works with TF <r1.0 | |
| import tensorflow as tf | |
| I = tf.placeholder(tf.float32, shape=[None,3], name='I') # input | |
| W = tf.Variable(tf.zeros_initializer(shape=[3,2]), dtype=tf.float32, name='W') # weights | |
| b = tf.Variable(tf.zeros_initializer(shape=[2]), dtype=tf.float32, name='b') # biases | |
| O = tf.nn.relu(tf.matmul(I, W) + b, name='O') # activation / output |
| import multiprocessing | |
| from multiprocessing.dummy import Pool as ThreadPool | |
| import numpy as np | |
| def my_multipro(items, func, max_cpus=12): | |
| """Do an embarrassingly parallel task using multiprocessing. | |
| Use this for CPU bound tasks. |
| # Remove anything linked to nvidia | |
| sudo apt-get remove --purge nvidia* | |
| sudo apt-get autoremove | |
| # Search for your driver | |
| apt search nvidia | |
| # Select one driver (the last one is a decent choice) | |
| sudo apt install nvidia-370 |
| n02119789 1 kit_fox | |
| n02100735 2 English_setter | |
| n02110185 3 Siberian_husky | |
| n02096294 4 Australian_terrier | |
| n02102040 5 English_springer | |
| n02066245 6 grey_whale | |
| n02509815 7 lesser_panda | |
| n02124075 8 Egyptian_cat | |
| n02417914 9 ibex | |
| n02123394 10 Persian_cat |