This file contains hidden or 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 = np.zeros([2,2]) | |
a[(0, 1),(0, 1)] = 1 | |
print(a) | |
return | |
====>>>> array([1, 0], | |
[0, 1]) | |
This file contains hidden or 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 = list(range(10)) | |
print("before : ", a) | |
b = np.random.permutation(a) | |
print("after : ", b) | |
====>>>> | |
before : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
after : [9 7 4 0 8 3 2 6 5 1] |
This file contains hidden or 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 step_function(x): | |
return np.where(x >= 0, 1, 0) | |
### It is equivalent to below code to give 1-D array to np.where. | |
### variables = np.where(condition, val1, val2) <=> variables = val1 if x >= 0 else val2 | |
def step_function(x:list): | |
return np.maximum(x, 0) |
This file contains hidden or 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 glob import glob | |
from os import path | |
def listup_file_name(data_path, extension=None, abspath=True): | |
extension = '.' + extension if extension else '' | |
if abspath: | |
return glob(data_path + '*' + extension) | |
else: | |
return glob(path.relpath(data_path + '*' + extension)) |
This file contains hidden or 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
<?php | |
public function createapp($email, $password){ | |
$url = "https://api.heroku.com/apps"; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password); | |
$headers = ['Accept: application/vnd.heroku+json; version=3',"Content-Type: application/json"]; |
This file contains hidden or 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 MeCab | |
def tokenization(text, dic_path, lex = None): | |
# -Oyomi (ヨミ付与) -Ochasen (ChaSen互換) -Odump (全情報を出力) | |
unknown_option = "-U %M\\t未知語,*,*,*,*,*,*,*,*\\n" | |
mecab_options = " ".join(["-d", dic_path, unknown_option]) | |
tagger = MeCab.Tagger(mecab_options) | |
parse = tagger.parse(text).replace('\t',',') | |
NewerOlder