AI - Platform

AI

인공지능은 사람이 정보를 분석하고 특성을 모델링하는 머신러닝이 지지부진 하다 2012년 부터 딥러닝 기반은 기계가 스스로 수 많은 정보에서 지식을 구성해 가는 시스템이 실제 구현되며 전환기를 맞고 있다. 과거 IBM의 Deep Blue는 체스를 목적으로 한 체스 전용 소프트웨어와 하드웨어를 인공지능으로 구현되었다. 최근 딥러닝을 기반으로하는 알파고 같은 기술은 하드웨어와 소프트웨어가 범용적 특성을 가지고 있다.[^3]

AI platform

AI 플랫폼은[^1] 플랫폼이 갖는 주요기능에 따라 음성지능, 언어지능, 시각지능, 공간지능, 감성 지능 플랫폼으로 구분한다. 적용 대상에 따라서 일반 소비자를 대상으로 다양한 서비스 제공이 가능한 범용 AI 플랫폼과 의료, 금융, 법률 등 특정 산업영역에 특화된 전문 AI 플랫폼으로 구분 할 수 있다.

인공지능 플랫폼의 활용

주요 IT기업이 “artificial intelligence as a service.” [^2] 으로 3rd party 기업/개발사 들이 앱/서비스를 만들어 가는 형태로 발전하고 있다.

개인/개발사들이 인공지능을 구현하는데 비해서 전문 플랫폼 사이의 성능 격차가 크다. 첫째로 기계학습에 제공하는 양질의 데이터는 큰 격차가 존재한다. 둘째로 비용, 시간 측면에서 기술과 경험이 부족해서 고도화된 서비스를 이용하는 면이 시간적 경제적으로 잇점이다.

자세히 보기

Nodejs middleware: Express

Express

Express는 NodeJS Webapplication framework이다.

Install express

Express는 크게 express 모듈과 CLI 모듈로 구성되어 있다.

  • express-generator: Express 프로젝트 및 템플릿 생성
  • exporess module: Node.js module

expres 명령을 이용해서 프로젝트를 생성하는 모듈로서 글로벌로 설치합니다.

1
2
$ mkdir myapp
$ cd myapp

npm의 package.json 를 초기화하자.

1
$ npm init

entry point: 에 app.js 혹은 index.js 시작점을 선언한다.

그리고 현재 프로젝트에 express 모듈을 설치하고 package.json에 의존성을 추가해 준다.

npm 5.0+ 이상은 npm install 시 모듈을 의존성 목록에 자동으로 추가한다.

1
$ npm install express

이전 버전은 아래같인 --save 를 명시해야 한다.

1
$ npm install express --save

Express Generator

express-generator 모듈은 손쉽게 프로젝트를 구성할 수 있게 해준다. CLI 명령으로 글로벌로 설치해 준다.

1
$ npm i -g express-generator

pug 뷰 엔진을 가진 myapp 이란 프로젝트를 생성하려면

1
$ express --view=pug myapp

프로젝트로 이동해 모듈을 설치하고 시작한다.

1
$ cd myapp && npm install

MacOS or Linux 에서 디버그 모드로 시작한다.

1
$ DEBUG=myapp:* npm start

Windows 에서

1
> set DEBUG=myapp:* & npm start

debug module

https://developer.ibm.com/node/2016/10/12/the-node-js-debug-module-advanced-usage/

https://expressjs.com/en/guide/writing-middleware.html

ExpressJS Middlewares

  • morgan:
    logger

  • body-parser:
    parse the body so you can access parameters in requests in req.body. e.g. req.body.name.

  • cookie-parser:
    parse the cookies so you can access parameters in cookies req.cookies. e.g. req.cookies.name.

  • serve-favicon:
    exactly that, serve favicon from route /favicon.ico. Should be call on the top before any other routing/middleware takes place to avoids unnecessary parsing.

주요 미들웨어

The following middlewares are not added by default, but it’s nice to know they exist at least:

  • compression:
    compress all request. e.g. app.use(compression())

  • session:
    create sessions. e.g. app.use(session({secret: 'Secr3t'}))

  • method-override:
    app.use(methodOverride('_method')) Override methods to the one specified on the _method param. e.g. GET /resource/1?_method=DELETE will become DELETE /resource/1.

  • response-time: app.use(responseTime()) adds X-Response-Time header to responses.

  • errorhandler:
    Aid development, by sending full error stack traces to the client when an error occurs. app.use(errorhandler()). It is good practice to surround it with an if statement to check process.env.NODE_ENV === ‘development’.

  • vhost:
    Allows you to use different stack of middlewares depending on the request hostname. e.g. app.use(vhost(‘.user.local’, userapp)) and app.use(vhost(‘assets-.example.com’, staticapp)) where userapp and staticapp are different express instances with different middlewares.

  • csurf:
    Adds a Cross-site request forgery (CSRF) protection by adding a token to responds either via session or cookie-parser middleware. app.use(csrf());

  • timeout:
    halt execution if it takes more that a given time. e.g. app.use(timeout(‘5s’));. However you need to check by yourself under every request with a middleware that checks if (!req.timedout) next();.