Skip to content

Instantly share code, notes, and snippets.

View achalddave's full-sized avatar

Achal Dave achalddave

View GitHub Profile

The default yaml library in lua does not handle YAML booleans correctly.

/tmp ~ th

  ______             __   |  Torch7
 /_  __/__  ________/ /   |  Scientific computing for Lua.
  / / / _ \/ __/ __/ _ \  |  Type ? for help
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch
 | http://torch.ch
@achalddave
achalddave / maptable_clearstate_bug.lua
Created February 20, 2017 17:20
Displays memory 'leak' with nn.MapTable after call to clearState()
--[[ Displays memory 'leak' with nn.MapTable after clearState() ]]--
local nn = require 'nn'
local cunn = require 'cunn'
model = nn.MapTable():add(nn.SpatialConvolution(3, 256, 3, 3, 1, 1, 1, 1, 1))
:cuda()
i = {torch.rand(30, 3, 224, 224):cuda(), torch.rand(30, 3, 224, 224):cuda()}
function check_mem() os.execute('nvidia-smi | grep luajit') end
@achalddave
achalddave / flop_computation_network.ipynb
Created October 11, 2017 18:35
Compute number of flops in a CNN
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@achalddave
achalddave / main.py
Last active February 13, 2018 01:55
Argparse load config from file
"""Use argparse to load arguments from file before command line.
MIT License
Copyright (c) 2018 Achal Dave
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
{"id": "lvis", "name": "LVIS", "children": [{"id": 1, "name": "entity.n.01", "children": [{"id": 194, "name": "physical_entity.n.01", "children": [{"id": 459, "name": "object.n.01", "children": [{"id": 2018, "name": "part.n.02", "children": [{"id": 1584, "name": "piece_of_cloth.n.01", "children": [{"id": 1590, "name": "sail.n.01", "children": []}, {"id": 1585, "name": "towel.n.01", "children": [{"id": 508, "name": "bath_towel.n.01", "children": []}, {"id": 1588, "name": "paper_towel.n.01", "children": []}, {"id": 1587, "name": "hand_towel.n.01", "children": []}, {"id": 1586, "name": "dishtowel.n.01", "children": []}]}, {"id": 1592, "name": "bandanna.n.01", "children": []}, {"id": 1589, "name": "dishrag.n.01", "children": []}]}, {"id": 2028, "name": "doorknob.n.01", "children": []}, {"id": 2024, "name": "wall_socket.n.01", "children": []}]}, {"id": 460, "name": "whole.n.02", "children": [{"id": 1986, "name": "natural_object.n.01", "children": [{"id": 2017, "name": "nest.n.01", "children": []}, {"id": 1991, "na
@achalddave
achalddave / patch_clip_model.sh
Last active April 27, 2022 06:37
Patch CLIP models to work with torch versions before 1.7
#!/bin/bash
###
# Patch CLIP models to work with PyTorch versions before 1.7.
# This script was tested with PyTorch 1.6 and CUDA 9.2 on the RN-50 and ViT-B-32 models.
###
if [[ "$#" != 1 ]] ; then
echo "Usage: $0 <clip-model-pt>"
echo "Example: $0 $HOME/.cache/clip/RN50.pt"
exit 1