반응형

Google Colaboratory - python 실습하기

https://colab.research.google.com/

 

Google Colaboratory

 

colab.research.google.com

 

https://research.google.com/colaboratory/faq.html

 

Google Colab

Colaboratory 자주 묻는 질문(FAQ) 기본 사항 Colaboratory란 무엇인가요? 줄여서 'Colab'이라고도 하는 Colaboratory는 Google 리서치팀에서 개발한 제품입니다. Colab을 사용하면 누구나 브라우저를 통해 임의의

research.google.com

Colaboratory

자주 묻는 질문(FAQ)

기본 사항

Colaboratory란 무엇인가요?link

줄여서 'Colab'이라고도 하는 Colaboratory는 Google 리서치팀에서 개발한 제품입니다. Colab을 사용하면 누구나 브라우저를 통해 임의의 Python 코드를 작성하고 실행할 수 있습니다. Colab은 특히 머신러닝, 데이터 분석, 교육에 적합합니다. 더 기술적으로 설명하면 Colab은 호스팅된 Jupyter 노트북 서비스로, 설정하지 않고 사용 가능하며 GPU를 포함한 컴퓨팅 리소스를 무료로 사용할 수 있습니다.

정말 무료인가요?link

예. Colab은 무료로 사용할 수 있습니다.

믿기 어려울 정도로 좋아 보이는데요. 어떤 제한사항이 있나요?link

Colab 리소스는 보장되거나 무제한으로 제공되지는 않으며 사용량 한도가 달라지기도 합니다. 이런 방식으로 운영해야 Colab에서 리소스를 무료로 제공할 수 있기 때문입니다. 자세한 내용은 리소스 한도를 참고하세요.

향상된 리소스를 더 안정적으로 사용하는 데 관심이 있다면 Colab Pro가 적합할 수 있습니다.

Colab 리소스는 상호작용 사용 사례에 우선 할당됩니다. 일괄 연산, 다른 사용자에게 부정적인 영향을 줄 수 있는 작업, 정책을 우회하는 작업 등은 금지됩니다. 다음은 Colab 런타임에서 허용되지 않는 사항입니다.

  • Colab과의 상호작용 연산과 관련이 없는 파일 호스팅, 미디어 게재 또는 기타 웹 서비스 제공
  • 토렌트 다운로드 또는 P2P 파일 공유 참여
  • 원격 데스크톱 또는 SSH 사용
  • 원격 프록시 연결
  • 암호화폐 채굴
  • 서비스 거부 공격 실행
  • 비밀번호 크래킹
  • 여러 계정을 사용하여 액세스 제한이나 리소스 사용 제한 우회
  • 딥페이크 생성

유료 사용자를 위한 추가 제한사항은 여기에서 확인하시기 바랍니다.

Jupyter와 Colab 사이에는 어떤 차이점이 있나요?link

Jupyter는 Colab의 기반이 되어 주는 오픈소스 프로젝트입니다. Colab을 사용하면 아무것도 다운로드하거나 설치, 실행하지 않고도 Jupyter 메모장을 다른 사람과 공유할 수 있습니다.

Colab 사용하기

 

Google Colab Free GPU Tutorial

https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d

 

Google Colab Free GPU Tutorial

Now you can develop deep learning applications with Google Colaboratory -on the free Tesla K80 GPU- using Keras, Tensorflow and PyTorch.

medium.com

Hello! I will show you how to use Google Colab, Google’s free cloud service for AI developers. With Colab, you can develop deep learning applications on the GPU for free.

Thanks to KDnuggets!

I am happy to announce that this blog post was selected as KDnuggets Silver Blog for February 2018! Read this on KDnuggets.

What is Google Colab?

Google Colab is a free cloud service and now it supports free GPU!

You can;

  • improve your Python programming language coding skills.
  • develop deep learning applications using popular libraries such as Keras, TensorFlow, PyTorch, and OpenCV.

The most important feature that distinguishes Colab from other free cloud services is; Colab provides GPU and is totally free.

Detailed information about the service can be found on the faq page.

Getting Google Colab Ready to Use

Creating Folder on Google Drive

Since Colab is working on your own Google Drive, we first need to specify the folder we’ll work. I created a folder named “app” on my Google Drive. Of course, you can use a different name or choose the default Colab Notebooks folder instead of app folder.

I created an empty “app” folder

Creating New Colab Notebook

Create a new notebook via Right click > More > Colaboratory

Right click > More > Colaboratory

Rename notebook by means of clicking the file name.

Setting Free GPU

It is so simple to alter default hardware (CPU to GPU or vice versa); just follow Edit > Notebook settings or Runtime>Change runtime type and select GPU as Hardware accelerator.

Running Basic Python Codes with Google Colab

Now we can start using Google Colab.

I will run some Basic Data Types codes from Python Numpy Tutorial.

It works as expected :) If you do not know Python which is the most popular programming language for AI, I would recommend this simple and clean tutorial.

Running or Importing .py Files with Google Colab

Run these codes first in order to install the necessary libraries and perform authorization.

 

When you run the code above, you should see a result like this:

Click the link, copy verification code and paste it to text box.

After completion of the authorization process, you should see this:

Now you can reach you Google Drive with:

 

install Keras:

!pip install -q keras

upload mnist_cnn.py file to app folder which is located on your Google Drive.

mnist_cnn.py file

run the code below to train a simple convnet on the MNIST dataset.

!python3 "/content/drive/My Drive/app/mnist_cnn.py"

As you can see from the results, each epoch lasts only 11 seconds.

반응형
반응형

conda update

 


Anaconda Prompt 에 들어오면 conda 패키지 관리자를 사용할 수 있게 됩니다.


> conda activate main

1.우선 conda 자체를 업그레이드 해줍니다.

> conda update -n base conda

2.다음으로 설치된 파이썬 패키지를 모두 최신 버전으로 업데이트 해줍니다.

>conda update -all 

3. tensorflow 를 설치합니다

>pip install tensorflow 

4.keras도 설치해줍니다

>pip install keras
반응형
반응형

Word Tokenization 단어 토큰화

 

자연어 처리에서 크롤링 등으로 얻어낸 코퍼스 데이터가 필요에 맞게 전처리되지 않은 상태라면, 해당 데이터를 사용하고자하는 용도에 맞게 토큰화(tokenization) & 정제(cleaning) & 정규화(normalization)하는 일을 하게 됩니다. 이번 챕터에서는 그 중에서도 토큰화에 대해서 배우도록 합니다.

주어진 코퍼스(corpus)에서 토큰(token)이라 불리는 단위로 나누는 작업을 토큰화(tokenization)라고 부릅니다. 토큰의 단위가 상황에 따라 다르지만, 보통 의미있는 단위로 토큰을 정의합니다.

이 챕터에서는 토큰화에 대한 발생할 수 있는 여러가지 상황에 대해서 언급하여 토큰화에 대한 개념을 이해합니다. 뒤에서 파이썬과 NLTK 패키지, KoNLPY를 통해 실습을 진행하며 직접 토큰화를 수행해보겠습니다.

 

 


## word_tokenize는 Don't를 Do와 n't로 분리하였으며, 
## 반면 Jone's는 Jone과 's로 분리한 것을 확인할 수 있습니다.
>from nltk.tokenize import word_tokenize  
>print(word_tokenize("Don't be fooled by the dark sounding name, Mr. Jone's Orphanage is as cheery as cheery goes for a pastry shop."))  
['Do', "n't", 'be', 'fooled', 'by', 'the', 'dark', 'sounding', 'name', ',', 'Mr.', 'Jone', "'s", 'Orphanage', 'is', 'as', 'cheery', 'as', 'cheery', 'goes', 'for', 'a', 'pastry', 'shop', '.']  


## WordPunctTokenizer는 구두점을 별도로 분류하는 특징을 갖고 있기때문에, 앞서 확인했던
## word_tokenize와는 달리 Don't를 Don과 '와 t로 분리하였으며, 
## 이와 마찬가지로 Jone's를 Jone과 '와 s로 분리한 것을 확인할 수 있습니다.
>from nltk.tokenize import WordPunctTokenizer  
>print(WordPunctTokenizer().tokenize("Don't be fooled by the dark sounding name, Mr. Jone's Orphanage is as cheery as cheery goes for a pastry shop."))
['Don', "'", 't', 'be', 'fooled', 'by', 'the', 'dark', 'sounding', 'name', ',', 'Mr', '.', 'Jone', "'", 's', 'Orphanage', 'is', 'as', 'cheery', 'as', 'cheery', 'goes', 'for', 'a', 'pastry', 'shop', '.']  


## 케라스 또한 토큰화 도구로서 text_to_word_sequence를 지원합니다. 이번에는 케라스로 토큰화를 수행해봅시다.
## 케라스의 text_to_word_sequence는 기본적으로 모든 알파벳을 소문자로 바꾸면서 온점이나 
## 컴마, 느낌표 등의 구두점을 제거합니다. 하지만 don't나 jone's와 같은 경우 아포스트로피는 보존하는 것을 볼 수 있습니다.
>from tensorflow.keras.preprocessing.text import text_to_word_sequence
>print(text_to_word_sequence("Don't be fooled by the dark sounding name, Mr. Jone's Orphanage is as cheery as cheery goes for a pastry shop."))
["don't", 'be', 'fooled', 'by', 'the', 'dark', 'sounding', 'name', 'mr', "jone's", 'orphanage', 'is', 'as', 'cheery', 'as', 'cheery', 'goes', 'for', 'a', 'pastry', 'shop']


## 표준으로 쓰이고 있는 토큰화 방법 중 하나인 Penn Treebank Tokenization의 규칙에 대해서 소개하고, 토큰화의 결과를 보도록 하겠습니다.
## 규칙 1. 하이푼으로 구성된 단어는 하나로 유지한다.
## 규칙 2. doesn't와 같이 아포스트로피로 '접어'가 함께하는 단어는 분리해준다. 
>from nltk.tokenize import TreebankWordTokenizer
>tokenizer=TreebankWordTokenizer()
>text="Starting a home-based restaurant may be an ideal. it doesn't have a food chain or restaurant of their own."
>print(tokenizer.tokenize(text))
['Starting', 'a', 'home-based', 'restaurant', 'may', 'be', 'an', 'ideal.', 'it', 'does', "n't", 'have', 'a', 'food', 'chain', 'or', 'restaurant', 'of', 'their', 'own', '.']
반응형

+ Recent posts