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 helloworld: | |
print('hello world') | |
return tmp |
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 lossFun(inputs, targets, hprev, cprev): | |
xs, hs, cs, is_, fs, os, gs, ys, ps= {}, {}, {}, {}, {}, {}, {}, {}, {} | |
hs[-1] = np.copy(hprev) # t=0일때 t-1 시점의 hidden state가 필요하므로 | |
cs[-1] = np.copy(cprev) | |
loss = 0 | |
H = hidden_size | |
# forward pass | |
for t in range(len(inputs)): | |
xs[t] = np.zeros((vocab_size, 1)) | |
xs[t][inputs[t]] = 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
import tensorflow as tf | |
import numpy as np | |
import tool as tool | |
import time | |
# data loading | |
data_path = 'C:/newscorpus.csv' | |
title, contents = tool.loading_data(data_path, eng=False, num=False, punc=False) | |
word_to_ix, ix_to_word = tool.make_dict_all_cut(title+contents, minlength=0, maxlength=3, jamo_delete=True) |
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 numpy as np | |
import pandas as pd | |
from collections import defaultdict | |
#################################################### | |
# loading function # | |
#################################################### | |
def loading_data(data_path, eng=True, num=True, punc=False): | |
# data example : "title","content" |
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
library(rpart) | |
library(Matrix) | |
library(stringr) | |
#################################### | |
# function # | |
#################################### | |
regression.perf_eval <- function(real,hat) { | |
MSE <- mean((real - hat)^2) | |
RMSE <- sqrt(MSE) |
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 os | |
import time | |
import datetime | |
from tensorflow import flags | |
import tensorflow as tf | |
import numpy as np | |
import cnn_tool as tool | |
class TextCNN(object): | |
""" |
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 numpy as np | |
import pandas as pd | |
import re | |
import tensorflow as tf | |
import random | |
#################################################### | |
# cut words function # | |
#################################################### |
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
class BranchingEntropy: | |
def __init__(self, min_length=2, max_length=7): | |
self.min_length = min_length | |
self.max_length = max_length | |
self.encoder = IntegerEncoder() | |
self.L = defaultdict(lambda: defaultdict(int)) | |
self.R = defaultdict(lambda: defaultdict(int)) |
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
class CohesionProbability: | |
def __init__(self, left_min_length=1, left_max_length=10, right_min_length=1, right_max_length=6): | |
self.left_min_length = left_min_length | |
self.left_max_length = left_max_length | |
self.right_min_length = right_min_length | |
self.right_max_length = right_max_length | |
self.L = defaultdict(int) | |
self.R = defaultdict(int) |
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
library(stringr) | |
# prepare corpus | |
corpus <- matrix(c(1,2,0,0,0,0, | |
3,1,0,0,0,0, | |
2,0,0,0,0,0, | |
3,3,2,3,2,4, | |
0,0,3,2,0,0, | |
0,0,4,1,0,0, | |
0,0,0,0,4,3, |
OlderNewer