This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
module Console | |
PROMPT = "\n>> ".freeze | |
def post_init | |
send_data PROMPT | |
send_data "\0" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FanCount | |
@queue = "FanCount" | |
include Mongoid::Document | |
field :page_id | |
field :fans | |
field :date, :type => DateTime | |
index :page_id, :unique => true, :background => true | |
index( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coll = db.foo | |
coll.drop() | |
coll.insert( { arr : [ { a : 1 } , { b : 2 } , { c : 3 } ] } ) | |
coll.insert( { arr : [ { a : 2 } , { b : 3 } , { c : 1 } ] } ) | |
coll.insert( { arr : [ { a : 3 } , { b : 1 } , { c : 2 } ] } ) | |
coll.ensureIndex( { arr : -1 } ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A Ruby implementation of | |
# the Viterbi algorithm based on the hidden Markov model (HMM) | |
# | |
# An original Python code: a Wikipedia page "Viterbi algorithm" at | |
# http://en.wikipedia.org/wiki/Viterbi_algorithm | |
# | |
# Author: MISHIMA, Hiroyuki | |
# | |
require 'pp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 訓練データ | |
(def text_classified_p '(["good" "bad" "good" "good"] | |
["exciting" "exciting"] | |
["good" "good" "exciting" "boring"])) | |
(def text_classified_n '(["bad" "boring" "boring" "boring"] | |
["bad" "good" "bad"] | |
["bad" "bad" "boring" "exciting"])) | |
;;多変数ベルヌーイモデル | |
(defn train [features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num_processes = 2 | |
batch_size = 1000 | |
threads_per_process = 10 | |
Parallel.map(0...num_processes, :in_processes => num_processes) do |i|· | |
User.connection.reconnect! | |
User.find_in_batches(:batch_size => batch_size,· | |
:start => (User.count/num_processes) * i,· | |
:conditions => ["id <= ?", (User.count/num_processes)*(i+1)]) do |batch|· | |
Parallel.map(batch, :in_threads => threads_per_process) do |record| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "irb" | |
load "#{ENV['HOME']}/.irbrc" | |
def IRB.run_config; end | |
ARGV.unshift "console" | |
load File.dirname(__FILE__) + "/rails" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch.utils.data | |
from torchvision import datasets, transforms | |
class PartialDataset(torch.utils.data.Dataset): | |
def __init__(self, parent_ds, offset, length): | |
self.parent_ds = parent_ds | |
self.offset = offset | |
self.length = length | |
assert len(parent_ds)>=offset+length, Exception("Parent Dataset not long enough") | |
super(PartialDataset, self).__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from batcountry import BatCountry | |
import numpy as np | |
from PIL import Image | |
from glob import glob | |
import os | |
import random | |
CAFFE_ROOT = '../caffe' | |
INPUT_PATH = 'input.jpg' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.nn.parameter import Parameter | |
def debug(debug_open, x, layername): | |
if debug_open: | |
print x.size(), 'after', layername | |
class PVANet(nn.Module): |
OlderNewer