Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import keras
from sklearn.model_selection import train_test_split
"""
ベクトルx,yは与えられているとする.
y = A * x となる行列Aを求める.
- 行列とベクトルの積, <https://stackoverflow.com/questions/46570963/keras-lambda-layer-for-matrix-vector-multiplication>
"""
@namakemono
namakemono / snli_lstm_with_w2v.py
Last active June 27, 2018 04:24
Trains a LSTM with Word2Vec on the SNLI dataset.
"""Trains a LSTM with Word2Vec on the SNLI dataset.
https://nlp.stanford.edu/projects/snli/
Get to 80.12% test accuracy after 18 epochs.
"""
import numpy as np
import pandas as pd
from gensim.models import KeyedVectors
@namakemono
namakemono / esim.py
Last active February 19, 2020 08:31
Implementation of ESIM(Enhanced LSTM for Natural Language Inference)
"""
Implementation of ESIM(Enhanced LSTM for Natural Language Inference)
https://arxiv.org/abs/1609.06038
"""
import numpy as np
from keras.layers import *
from keras.activations import softmax
from keras.models import Model
def StaticEmbedding(embedding_matrix):
@namakemono
namakemono / decomposable_attention.py
Created August 17, 2017 23:53
Decomposable Attention with Keras.
from keras.layers import *
from keras.activations import softmax
from keras.models import Model
"""
References
----------
[1]. Parikh, Ankur P., et al. "A decomposable attention model for natural language inference." arXiv preprint arXiv:1606.01933 (2016).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import requests
import pandas as pd
import datetime
"""
coincheckのPublic API用データ取得ツール
# mnist_expert.py
import tensorflow as tf
import os
if not os.path.exists("input_data.py"):
os.system("curl https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/examples/tutorials/mnist/input_data.py -o input_data.py")
import input_data
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1,1,1,1], padding='SAME')