Skip to content

Instantly share code, notes, and snippets.

@nagadomi
nagadomi / otto.conf
Created May 19, 2015 03:03
my xgboost configuration for kaggle-otto competition
# local-CV: 0.436
# number of threads
nthread=8
# fixed random seed
seed=12
# whether create binary buffer for text input, this normally will speedup loading (NO)
use_buffer = 0
# The path of training data
@nagadomi
nagadomi / randomwrite.rb
Created May 8, 2015 15:33
turbovisor segfault
require 'open-uri'
TARGET_URL = "http://localhost:8888/"
TARGET_DIR = "./"
CORE_FILE = "./core"
def random_file_update
rng = Random.new
10000.times do |i|
filename = File.join(TARGET_DIR, sprintf("%d", i % 10))
@nagadomi
nagadomi / pagerank.lua
Last active August 29, 2015 14:16
PageRank
local function pagerank(mat, alpha, epsilon)
alpha = alpha or 0.85
epsilon = epsilon or 1.0e-5
local state = torch.Tensor(mat:size(1)):fill(1.0 / mat:size(1))
local p = mat:clone()
local alpha_not = ((1.0 - alpha) / state:size(1))
for i = 1, mat:size(1) do
p[i]:div(mat[i]:sum() + 1.0e-6)
@nagadomi
nagadomi / LeakyReLU.lua
Last active October 25, 2015 12:46
LeakyReLU
--- mynn.lua
mynn = {} -- Define your own namespace.
--- LeakyReLU.lua
-- Define LeakyReLU module under your own namespace.
local LeakyReLU, parent = torch.class('mynn.LeakyReLU','nn.Module')
function LeakyReLU:__init(negative_scale)
parent.__init(self) -- Call the super class constructor
require 'cutorch'
require 'cunn'
local function build_model()
-- a CNN
local model = nn.Sequential()
model:add(nn.SpatialConvolutionMM(3, 128, 5, 5, 1, 1))
model:add(nn.ReLU())
model:add(nn.SpatialMaxPooling(2, 2, 2, 2))
model:add(nn.View(10 * 10 * 128))
@nagadomi
nagadomi / csv.lua
Last active April 28, 2020 14:52
csvigo example
-- sudo luarocks install csvigo
-- でインストールしておく
require 'csvigo'
--[[ test.csv
a,b,c,d
1,2,3,4
5,5,3,3
--]]
@nagadomi
nagadomi / nin3layer_model.lua
Last active July 12, 2016 11:44
mavenlin's 3-layer NIN
require 'cunn'
require './lib/SpatialAveragePooling'
-- reference: https://gist.github.com/mavenlin/e56253735ef32c3c296d
local function normal_init(m, u, s, bias)
m.weight:normal(u, s)
if bias == nil then
m.bias:normal(u, s)
else
/* Left 4 Dead 2 Panic Events */
#include <sourcemod>
public OnPluginStart()
{
/* Hook Panic Create event after it has happened */
HookEvent("create_panic_event", OnPanicCreate);
/* Hook Left Player event after it has happened */
HookEvent("player_left_start_area", OnPlayerLeftStartArea);
}
// Force strict semicolon mode
// bug fix by def075
#pragma semicolon 1
#include <sourcemod>
#define PLUGIN_VERSION "0.666 beta- fix"
new String:g_gameMode[64];
new Handle:g_mapMenu = INVALID_HANDLE;