Skip to content

Instantly share code, notes, and snippets.

자연어 전처리 과정 (클렌징)

  1. 문장 띄어쓰기 처리
  2. 문장 분리
  3. 맞춤법 처리
  4. 정규식 처리
  5. 형태소 토크나이징 or subword 토크나이징

문장 띄어쓰기 처리

conda create -n django python=3.6
conda activate django
@yunsu3042
yunsu3042 / models.py
Last active October 23, 2019 11:29
Models
from django.db import models
from django.contrib.auth import get_user_model
User = get_user_model()
class Category(models.Model):
name = models.CharField(max_length=100)
category_title = models.CharField(max_length=200, blank=True)
rating = models.IntegerField(null=True, blank=True)
def __str__(self):
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import os
import sys
import time
import tensorflow as tf
# -*- coding: utf_8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import cv2
import argparse
import pickle
def _load_image(filename) :
cv2_arr = cv2.imread(filename)
cv2_arr = rescale(cv2_arr,size=(224, 224))
arr = np.asarray(cv2_arr, dtype="float32")
return arr
def rescale(cv2_arr, size):
return cv2.resize(cv2_arr, dsize=size, interpolation=cv2.INTER_CUBIC)
def load_images(img_paths):
@yunsu3042
yunsu3042 / Memory.md
Last active June 13, 2018 07:57
Cache

Memory

  • 메모리란 크면 느리고, 빠르면 작을 수 밖에 없는 운명적인 한계를 갖습니다.
  • 느리면 가격이 저렴하기 때문에 크게 구성할 수 있고, 빠르면 가격이 비싸기 때문에 작게 구성해야 하는 경제적인 이유가 있고
  • 작은 메모리는 CPU와 가깝게 둘 수 있고, 큰 메모리는 CPU로 부터 멀리 두게 되는 지역적인 이유로 인한 속도 저하도 있을 것 입니다.

메모리의 한계

  • 메모리는 위에서 설명한 것처럼 하나가 길면 다른 하나가 짧아지는 운명적인 한계를 갖습니다.
  • 또한 CPU의 성능이 지수적으로 증가했음에도 메모리 Access spped는 1차함수로 증가하여 CPU의 성능과 상당한 격차가 벌어지게 됩니다.
@yunsu3042
yunsu3042 / exception.md
Last active June 13, 2018 05:13
exception

Exceptional Control Flow

Control Flow

  • 프로세서는 전원이 공급되는 동안 같은 일만 반복한다. 인스트럭션을 읽고 수행하는 일만을 반복한다.
  • CPU는 Branch와 call, ret와 같은 인스트럭션에 대해서 프로그램 수준에서 Control을 교환하는 수준으로 일하고 있다.
  • 하지만 좀 더 큰 시스템, 즉 컴퓨터 시스템에서 본다면 이렇게 간단한 수준의 Control Flow으로는 시스템 운영이 불가능하다.
  • System Timer에도 반응해야하고, 유저의 키보드 입력, 디스크와 어댑터로부터 데이터의 입력 등 수 많은 Control Flow의 제어가 필요하다. 우리는 그것을 Exceptional Control Flow라고 부른다.

Exceptional Control Flow

Low Level

@yunsu3042
yunsu3042 / Markov Process.md
Last active August 21, 2018 10:53
Markov Process

Markov Chain

마르코브 체인(MC)은 여러 개의 state들의 연결관계로 이루어진 그래프이다. MC의 state의 개수는 유한할 수도 있고 무한할 수도 있다.

State of chain

Markov chain의 여러가지 상태의 정의에 대해서 알아보자. state란 다음 두 가지 의미 모두 쓰여 햇갈릴 수도 있다.

  1. Markov chain의 가장 작은 구성 요소이다. state $i$는 그래프의 하나의 노드로 생각하면 된다.
  2. state와 chain의 상태를 다룬다. 다음에 배울 Communicate는 state $i$$j$간의 상태를 의미하기도 하며 chain의 상태를 의미하기도 한다.

Accessible

  • state $i$는 state $j$에 대해서 accessible : if 어떤 양수 $n$에 대해서 $P_{i, j}^n > 0$을 만족한다
import Multiplexer::*;
interface BarrelShifterRight;
method ActionValue#(Bit#(64)) rightShift(Bit#(64) val, Bit#(6) shiftAmt, Bit#(1) shiftValue);
endinterface
module mkBarrelShifterRight(BarrelShifterRight);
method ActionValue#(Bit#(64)) rightShift(Bit#(64) val, Bit#(6) shiftAmt, Bit#(1) shiftValue);
/* TODO: Implement right barrel shifter using six multiplexer */
Bit#(64) shiftedVal;