Skip to content

Instantly share code, notes, and snippets.

View z-a-f's full-sized avatar
🏠
Working from home

Zafar z-a-f

🏠
Working from home
  • Hoofs and Horns, Inc.
  • Mountain View, CA
View GitHub Profile
@z-a-f
z-a-f / tin.py
Created July 31, 2019 16:31
Tiny ImageNet Dataset for PyTorch
import imageio
import numpy as np
import os
from collections import defaultdict
from torch.utils.data import Dataset
from tqdm.autonotebook import tqdm
dir_structure_help = r"""
HOMEBREW_VERSION: 2.1.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 37714b5ce1e4909d4d61de2af98343c7012f7cd9
Last commit: 5 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 05261c45dc7e515bda632a28d5d3a2bb083b97d0
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /Users/zaf/.brew
HOMEBREW_CELLAR: /Users/zaf/.brew/Cellar
HOMEBREW_REPOSITORY: /Users/zaf/.brew
## User
[user]
name =
email =
## Colors
[color]
ui = auto
[color "branch"]
@z-a-f
z-a-f / MobileNetV2_CIFAR10_qat.py
Created July 21, 2020 07:52
MobileNetV2 model adopted for CIFAR10 and prepared for QAT
import torch
import torch.nn as nn
from torch.quantization import QuantStub, DeQuantStub
from torch.quantization import fuse_modules
import os
__all__ = ['MobileNetV2', 'mobilenet_v2']
def _make_divisible(v, divisor, min_value=None):
-- std::exception_ptr is supported.
-- Turning off deprecation warning due to glog.
-- Current compiler supports avx2 extension. Will build perfkernels.
-- Current compiler supports avx512f extension. Will build fbgemm.
-- Building using own protobuf under third_party per request.
-- Use custom protobuf build.
--
-- 3.11.4.0
-- Caffe2 protobuf include directory: $<BUILD_INTERFACE:/home/z-a-f/Git/pytorch-dev/pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
-- Trying to find preferred BLAS backend of choice: MKL
U __cxa_allocate_exception
U __cxa_atexit
U __cxa_guard_acquire
U __cxa_guard_release
U __cxa_init_primary_exception
U __dso_handle
0000000000000000 V DW.ref.__gxx_personality_v0
U _GLOBAL_OFFSET_TABLE_
0000000000000000 t _GLOBAL__sub_I_GenerateKernelU8S8S32ACC32.cc
U __gxx_personality_v0
rc_params = {
'font.family' : 'monospace',
'font.style' : 'normal',
'font.variant' : 'normal',
'font.weight' : 'bold',
'font.stretch' : 'normal',
'font.size' : 18,
'text.usetex' : True,
'xtick.labelsize' : 18,
'ytick.labelsize' : 18,
$> python test/backward_compatibility/dump_all_function_schemas.py -f ~/Desktop/test.txt
terminate called after throwing an instance of 'c10::Error'
what(): Can't redefine method: __setstate__ on class: __torch__.torch.classes.quantized.Conv2dPackedParamsBase
Exception raised from addMethod at /home/zafar/Git/pytorch-dev/pytorch-convtranspose-new/aten/src/ATen/core/type.cpp:1013 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x68 (0x7fefea29dce8 in /home/zafar/Git/pytorch-dev/pytorch-convtranspose-new/torch/lib/libc10.so)
frame #1: c10::ClassType::addMethod(torch::jit::Function*) + 0x295 (0x7fefe4160ad5 in /home/zafar/Git/pytorch-dev/pytorch-convtranspose-new/torch/lib/libtorch_cpu.so)
frame #2: torch::class_<ConvPackedParamsBase<2> > register_conv_params<2>() + 0x22c (0x7fefe4602d4c in /home/zafar/Git/pytorch-dev/pytorch-convtranspose-new/torch/lib/libtorch_cpu.so)
frame #3: <unknown function> +
@z-a-f
z-a-f / philosophy_of_ai.md
Last active August 17, 2020 04:45
LIst of AI books

Philosophy of the Artificial Intelligence

These are the books that I have on my to-read list that I believe cover the history, the philosophy, and the prerequisites for artificial intelligence. Note: this has very little to do with the machine or deep learning. The list is not in any particular order, just listing as it comes to mind

  • "On the Genealogy of Modals and Ecce Homo", Friedrich Nietzsche, Walter Kaufmann
  • "Plato: Complete Works", Plato, John Cooper
  • "An Enquiry Concerning Human Understanding: with Hume's Abstract of A Treatise of Human Nature and A Letter from a Gentleman to His Friend in Edinburgh", David Hume, Eric Steinberg
  • "Grounding for the Metaphysics of Morals: With on a Supposed Right to Lie Because of Philanthropic Concerns", Immanuel Kant, James Ellington
Testing: BNRelu(
(bn): BatchNorm1d(3, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
)
input graph: graph(%self.1 : __torch__.quantization.test_quantize_jit.BNRelu,
%input.1 : Float(2:30, 3:10, 10:1, requires_grad=0, device=cpu)):
%25 : __torch__.torch.nn.modules.activation.ReLU = prim::GetAttr[name="relu"](%self.1)
%24 : __torch__.torch.nn.modules.batchnorm.BatchNorm1d = prim::GetAttr[name="bn"](%self.1)
%28 : Tensor = prim::CallMethod[name="forward"](%24, %input.1)
%29 : Tensor = prim::CallMethod[name="forward"](%25, %28)