Skip to content

Instantly share code, notes, and snippets.

View cocomoff's full-sized avatar
🏠
Working from home

Keisuke OTAKI cocomoff

🏠
Working from home
View GitHub Profile
@cocomoff
cocomoff / pytorch_seq2seq_debug_example.py
Last active December 18, 2018 13:15
pytorch_seq2seq_debug_example.ipynb
# coding: utf-8
# In[1]:
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
@cocomoff
cocomoff / ch07_pytorch.ipynb
Created December 18, 2018 13:43
ch07_pytorch.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cocomoff
cocomoff / ch07_debug.ipynb
Created December 18, 2018 13:45
ch07_debug.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cocomoff
cocomoff / hatena.py
Created January 5, 2019 13:35
hatenablog-title-count
from bs4 import BeautifulSoup
import requests
import lxml
from collections import defaultdict, Counter
N = 100
l_title = []
for i in range(1, N):
r = requests.get("http://URL/archive/?page={}".format(i))
soup = BeautifulSoup(r.text, 'lxml')
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
G1 = nx.Graph()
G1.add_nodes_from(["A", "B", "C", "D", "E"])
G1.add_edges_from([("A", "B"), ("A", "C"), ("A", "D"), ("D", "E")])
G2 = nx.Graph()
G2.add_nodes_from([1, 2, 3, 4, 5, 6])
@cocomoff
cocomoff / min_tree_sandbox.py
Created January 14, 2019 13:38
最低限のコード(正しく機能しない場合が多数)
class Tree(object):
def __init__(self, label, left=None, right=None):
self.label = label
self.left = left
self.right = right
def __str__(self):
return str(self.label)
def get_dfs_label(t):
@cocomoff
cocomoff / taxi_simple.py
Created April 18, 2017 14:56
Simple Taxi Domain example using OpenAI Gym
import gym
from gym.wrappers import Monitor
def main():
GAME = "Taxi-v2"
env = gym.make(GAME)
n_state = env.observation_space.n
n_action = env.action_space.n
env = Monitor(env, "taxi_simple", force=True)
#[derive(Debug)]
struct Mafuyu {
max_value: usize,
list_of_values: Vec<usize>,
}
impl Mafuyu {
pub fn new(lov: Vec<usize>) -> Mafuyu {
let max_v = lov.iter().max().unwrap();
Mafuyu{max_value: *max_v, list_of_values: lov}
#[derive(Debug)]
struct Mafuyu2 {
list_of_values: Vec<usize>,
max_value: usize,
}
impl Mafuyu2 {
pub fn new(lov: Vec<usize>) -> Mafuyu2 {
let max_v = lov.iter().max().unwrap();
Mafuyu2{list_of_values: lov, max_value: *max_v}
@cocomoff
cocomoff / many_mafuyu_code.rs
Created June 3, 2019 12:56
動いたり動かなかったりするコード
#[derive(Debug)]
struct Mafuyu {
max_value: usize,
list_of_values: Vec<usize>,
}
impl Mafuyu {
pub fn new(lov: &Vec<usize>) -> Mafuyu {
let max_v = lov.iter().max().unwrap();
Mafuyu {max_value: *max_v, list_of_values: lov.to_vec()}