Skip to content

Instantly share code, notes, and snippets.

View AjayTalati's full-sized avatar

Hello :) AjayTalati

  • London, UK
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AjayTalati
AjayTalati / multilabel_example.py
Created April 29, 2017 12:48 — forked from bartolsthoorn/multilabel_example.py
Simple multi-laber classification example with Pytorch and MultiLabelSoftMarginLoss (https://en.wikipedia.org/wiki/Multi-label_classification)
import torch
import torch.nn as nn
import numpy as np
import torch.optim as optim
from torch.autograd import Variable
# (1, 0) => target labels 0+2
# (0, 1) => target labels 1
# (1, 1) => target labels 3
train = []
#!/usr/bin/env python3
import argparse
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
plt.style.use('bmh')
import numpy as np
import pandas as pd
@AjayTalati
AjayTalati / main_single.py
Created March 18, 2017 17:05
Continuous action A3C
# Reference - Deepmind A3C's paper, https://arxiv.org/pdf/1602.01783.pdf
# See section 9 - Continuous Action Control Using the MuJoCo Physics Simulator
#
# Code based on https://github.com/pfre00/a3c
import argparse
import torch
import torch.multiprocessing as mp
import gym
import torch.nn as nn
@AjayTalati
AjayTalati / CEM.py
Created February 4, 2017 01:23 — forked from floodsung/CEM.py
This solution is mainly from John Schulman's Deep Reinforcement Learning Lab script in Machine Learning Summer School 2016
import numpy as np
import gym
from gym.spaces import Discrete,Box
# -------------------------------------------
# Policies
# -------------------------------------------
class DeterministicDiscreteActionLinearPolicy(object):
@AjayTalati
AjayTalati / polar.rb
Last active August 29, 2015 14:26 — forked from telent/polar.rb
Interface with a polar bluetooth hrm from ruby (linux)
require 'pp'
require 'socket'
module BluetoothPolarHrm
AF_BLUETOOTH=31 # these are correct for the Linux Bluez stack
BTPROTO_RFCOMM=3
class << self
def connect_bt address_str,channel=1
bytes=address_str.split(/:/).map {|x| x.to_i(16) }
s=Socket.new(AF_BLUETOOTH, :STREAM, BTPROTO_RFCOMM)
@AjayTalati
AjayTalati / ProFi.lua
Last active August 29, 2015 14:23 — forked from perky/ProFi.lua
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
----------------------------------------------------------------------
-- CIFAR 8x8
opt.scale = 8
opt.geometry = {3, opt.scale, opt.scale}
local input_sz = opt.geometry[1] * opt.geometry[2] * opt.geometry[3]
local numhid = 600
model_D = nn.Sequential()
model_D:add(nn.Reshape(input_sz))
model_D:add(nn.Linear(input_sz, numhid))
model_D:add(nn.ReLU())
import bpy
# get the material
mat = bpy.data.materials['Material']
# get the nodes
nodes = mat.node_tree.nodes
# clear all nodes to start clean
for node in nodes:
import re
bvh_file = "Example1.bvh"
def identifier(scanner, token): return "IDENT", token
def operator(scanner, token): return "OPERATOR", token
def digit(scanner, token): return "DIGIT", token
def open_brace(scanner, token): return "OPEN_BRACE", token
def close_brace(scanner, token): return "CLOSE_BRACE", token