Skip to content

Instantly share code, notes, and snippets.

- 回答が途中で切れる場合は、全体の回答にかかるチャット数と現在のチャットの番号を3/10といった形式で明示してください。
# /bin/bash
echo "Hello, world!"
@spin-glass
spin-glass / lda_graphical_model.tex
Last active July 29, 2021 12:47
graphical model of LDA
\documentclass[a4j,12pt,dvipdfmx]{jsarticle}
\usepackage{tikz}
\usepackage[dvipdfmx]{hyperref}
\usetikzlibrary{positioning,fit,arrows.meta}
\begin{document}
\begin{tikzpicture}
\node[draw,circle,minimum size=1cm] (alpha) {$\alpha$};
\node[draw,circle,minimum size=1cm, right=1cm of alpha] (theta) {$\theta_d$};
\node[draw,circle,minimum size=1cm, right=1cm of theta] (z) {$z_{d,i}$};
@spin-glass
spin-glass / component.html
Created May 19, 2017 05:26
Vue.jsの親子関係
<div id='list'>
<child v-for='item in items' :key='item.id' :child='item'></child>
</div>
<script>
Vue.component('child', {
props: ['child'],
template: '<li>{{ child.name }}</li>'
})
@spin-glass
spin-glass / 2-class_one-hot_label
Created May 2, 2017 05:09
2クラス分類時のone-hot label
from sklearn.preprocessing import LabelBinarizer, OneHotEncoder
label = ['a', 'b', 'a']
binarized_label = LabelBinarizer().fit_transform(label) # [[1], [2], [2]]
# 以下は2クラスの場合のみ必要
one-hot_label = OneHotEncoder().fit_transform(binarized_label).toarray()
@spin-glass
spin-glass / one-hot lable
Created May 2, 2017 00:57
one-hot label
from keras.utils import np_utils
from sklearn.preprocessing import LabelEncoder
import numpy as np
feature_labels = np.array([1, 1, 2, 3, 4, 3, 4])
encoder = LabelEncoder()
encoder.fit(feature_labels)
feature_labels = encoder.transform(feature_labels)
feature_labels = np_utils.to_categorical(feature_labels)
@spin-glass
spin-glass / check_continuous.py
Created April 14, 2017 06:29
リスト内の連続で値を持つような場合、その期間と期間内の平均のリストが欲しい
lists = [0, 1, 2, 0, 1, 4, 0, 2, 3, 3]
# periods = [2, 2, 3]
# average = [1.5, 2.5, 2.6]
# が欲しい
periods = []
average = []
amount = 0
k = 0
N = gets.to_i
nums = gets.split.map(&:to_i)
cnt = 0;
nums.each_with_index{|num, i|
nums_dup = nums.dup #浅いコピー
nums_dup.delete_at(i)
cnt += 1 if nums_dup.find{|n| n + num == 256}
}
puts cnt > 0 ? "yes" : "no"
public class Client {
public static void main (String[] args) {
System.out.println("start");
Factory myFactory;
myFactory = new Factory();
Component myComponent = myFactory.getComponent();
myComponent.prtTicket();
System.out.println("end");
}
}