반응형

챗봇 시작해보기   https://www.slideshare.net/ssusercf5d12/ss-69518853


Python 으로 Slackbot 개발하기   https://www.slideshare.net/ssusercf5d12/python-slackbot


20170227 파이썬으로 챗봇_만들기     https://www.slideshare.net/KimSungdong1/20170227-72644192


머신러닝의 자연어 처리기술(I)    https://www.slideshare.net/ssuser06e0c5/i-64267027


인공지능, 기계학습 그리고 딥러닝  https://www.slideshare.net/JinwonLee9/ss-70446412  


[F2]자연어처리를 위한 기계학습 소개   https://www.slideshare.net/deview/f2-14341235





.

반응형
반응형



** 설치된 모듈의 위치정보 등 알아내기


    --  pip show  설치된모듈이름



 



TensorFlow on Windows: “Couldn't open CUDA library cudnn64_5.dll”




First of all, note that cuDNN is not distributed with the rest of the CUDA toolkit, so you will need to download it separately from the NVIDIA website. On Windows, it is distributed as a ZIP archive, so you must extract it and find the directory containing cudnn64_5.dll. For example, if you extract it to C:\tools\cuda, the DLL will be in C:\tools\cuda\bin\cudnn64_5.dll. Finally, you can add it to your path by typing the following at the command prompt:


C:\> set PATH=%PATH%;C:\tools\cuda\bin

C:\> python

...

>>> import tensorflow as tf


 

 I didn't have such issues with TensorFlow 0.12.1 (installed with pip install tensorflow==0.12.1):

 



---------------------------------------------------------------------------------

KNL

---------------------------------------------------------------------------------


matplotlib install  -  http://matplotlib.org/faq/installing_faq.html


> pip install matplotlib


or 


> git clone git://github.com/matplotlib/matplotlib.git

> cd matplotlib

> python setup.py install

> python setup.py develop


matplotlib test 

http://matplotlib.org/faq/howto_faq.html#how-to-search-examples


---------------------------------------------------------------------------------


konlpy install - http://konlpy.org/ko/v0.4.3/install/


> pip install --upgrade pip

> pip install JPype1-0.5.7-cp27-none-win_amd64.whl


> pip install konlpy


Binary Install

Ensure you have installed Anaconda/Miniconda. Instructions can be found here.

Install from the conda-forge software channel:


conda install -c conda-forge jpype1


$ pip install wheel


jpype  download : http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype


---------------------------------------------------------------------------------


JAVA_HOME 설정 

java 설치 - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


환경변수 - JAVA_HOME  C:\Program Files\Java\jdk1.8.0_121


---------------------------------------------------------------------------------


To install this package with conda run: https://anaconda.org/anaconda/gensim


> conda install -c anaconda gensim=1.0.1


To install this package with conda run: https://anaconda.org/anaconda/scipy


> conda install -c anaconda scipy=0.19.0



---------------------------------------------------------------------------------


sklearn install


https://sourceforge.net/projects/scikit-learn/files/


sklearn test 

http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html


---------------------------------------------------------------------------------


Activate the conda environment by issuing the following command:


C:> activate tensorflow

 (tensorflow)C:>  # Your prompt should change 




예제 :: 

Saved model checkpoint to D:\PythonProject\cnn-text-classification-tf-master\runs\1490667625\checkpoints\model-1000



word2vec_example - https://gist.github.com/solaris33/8ce9913dea1aa4225876cbcfdd2963be#file-word2vec_example-py



Pycharm & tensorflow & Anaconda = http://yeramee.tistory.com/1


anaconda > tensorflow install : http://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow





starting jupyter notebook

> jupyter notebook 

or 

> jupyter notebook --port 9999





5-1. 텐서플로우(TensorFlow)를 이용해 자연어를 처리하기(NLP) – Word Embedding(Word2vec) :: http://solarisailab.com/archives/374


jupyter notebook 사용하기 : http://goodtogreate.tistory.com/entry/IPython-Notebook-%EC%84%A4%EC%B9%98%EB%B0%A9%EB%B2%95




.

반응형
반응형


-- CMD에서 tensorflow 설치 유무 확인 


$ python -c "import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))""





.

반응형
반응형

Python socket programming



Python socket programming

1. Python : Socket Program Produced by Tae Young Lee

2. 클라이언트/서버 아키텍처 서버가 하나 이상의 클라이언트(사용자)에게 '서비스'를 제공 listen

3. Socket • 소켓은 '통신 종단점'이라는 개념을 구체화한 컴퓨터 네트 워크 데이터 구조 • 네트워크를 사용하는 애플리케이션은 통신을 시작하기 전 에 항상 소켓을 만들어야 함 • 소켓 없이는 통신을 시작할 수 없음 • 원래 소켓은 실행중인 프로그램(프로세스)이 같은 호스트 안에 실행 중인 다른 프로그램과 통신하기 위해 개발됨

4. Socket 유형 • 유닉스 소켓 – AF_UNIX 라는 '패밀리 이름' 을 가진다. AF는 주소 패밀리(Address family)를 의미. – 쉽게 클라이언트와 서버가 유닉스 환경의 동일한 컴퓨터에 존재해야 한다는 뜻. – 이 소켓은 파일 기반이다. 소켓의 기반 구조가 파일 시스템을 통해 지원됨 – 파일 시스템은 같은 호스트에서 실행 중인 프로세스 사이에 지속적으 로 공유되므로, 합리적인 방법이라고 할 수 있다. • 네트워크 기반 – 패밀리 이름은 AF_INET 이다. – 클라이언트와 서버가 인터넷 어디서든 존재할 수 있다는 의미를 갖는 다 • 파이썬은 AF_UNIX, AF_NETLINK, AF_TIPC, AF_INET{,6} 패 밀리를 지원

5. 연결 방식에 따른 분류 • 연결 지향 소켓(connection oriented) – 통신을 하기 전에 반드시 연결 돼 있어야 한다(전화를 거는 것과 유사) – 레코드 경계 없이 데이터를 순서대로 신뢰성 있게 중복없이 전 달. 각 메세지는 여러 조각으로 나뉘어서 반대편에 확실히 전달 된 다음에 다시 순서대로 한데 묶인 후 기다리는 애플리케이션 에 전달 – 연결 지향 소켓을 구현한 프로토콜(protocol)로는 전송 제어 프 로토콜(TCP, Trasmission Control Protocol) 이 있으며, 이 소켓을 만드려면 소켓 유형으로 SOCK_STREAM(스트림 소켓)을 지정 – 이 소켓은 네트워크상에서 IP를 호스트를 찾기 위해 사용하기 때 문에 두 프로토콜의 이름을 붙여 TCP/IP 라고 함.

6. • 비연결형 소켓(connectionless) – 스트림 소켓과 대비되는 데이터그램(Datagram) 유형의 비연결 – 통신 시 최초 연결하는 과정이 필요 없음 – 데이터 전달 과정에서 순서나 신뢰성 이나 중복 방지를 보장할 수 없음. 이는 메세지가 연결 지향 소켓처럼 조각으로 나뉘지 않 고 통째로 송신된다는 것을 의미(우편 서비스에 비유) – 연결 지향 소켓은 가상 회선을 맨 처음 만들고 유지하기 위해 상 당한 부가 비용이 발생 비연결 지향 소켓은 이런 부담이 덜하고 성능면에서 더 좋다. – 데이터그램 소켓을 구현한 프로토콜로는 (UDP, User Datagram Protocol)이 있고, UPD 소켓을 만들려면 SOCK_DGRAM을 소켓 유형으로 지정. – 이 소켓도 IP를 네트워크상에서 호스트를 찾기 위해 사용 UPD/IP라고도 부름

7. Socket의 동작 과정

8. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM)

9. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM) svrsock.bind(('127.0.0.1', 7799))

10. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM) svrsock.bind(('127.0.0.1', 7799)) svrsock.listen(1)

11. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM) svrsock.bind(('127.0.0.1', 7799)) svrsock.listen(1) conn, addr = svrsock.accept() addr ('127.0.0.1', 50933)

12. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM) svrsock.bind(('127.0.0.1', 7799)) svrsock.listen(1) conn, addr = svrsock.accept() addr ('127.0.0.1', 50933) conn.recv(1024)

13. conn.close() from socket import * svrsock = socket(AF_INET, SOCK_STREAM) svrsock.bind(('127.0.0.1', 7799)) svrsock.listen(1) conn, addr = svrsock.accept() addr ('127.0.0.1', 50933) conn.recv(1024) conn.close()

14. conn.close() from socket import * clientsock = socket(AF_INET, SOCK_STREAM)

15. conn.close() from socket import * clientsock = socket(AF_INET, SOCK_STREAM) clientsock.connect(('127.0.0.1',7799))

16. conn.close() from socket import * clientsock = socket(AF_INET, SOCK_STREAM) clientsock.connect(('127.0.0.1',7799)) clientsock.send('Hi, it is me.')

17. Blocking & Non-Blocking • blocking 모드일 때 accept, recv, send 호출할 때 연결하려 고 하는 client 가 없을 때 무한정 기다리는 것 • non-blocking 모드일 때는 위와 같은 상황에서 일정한 시 간을 기다려도 응답이 없을 때 예외가 발생

18. • https://pl.python.org/docs/lib/socket-objects.html • setblocking(flag) Set blocking or non-blocking mode of the socket: if flag is 0, the socket is set to non- blocking, else to blocking mode. Initially all sockets are in blocking mode. In non- blocking mode, if a recv() call doesn't find any data, or if a send() call can't immediately dispose of the data, a error exception is raised; in blocking mode, the calls block until they can proceed. s.setblocking(0) is equivalent to s.settimeout(0); s.setblocking(1) is equivalent to s.settimeout(None). • settimeout(value)Set a timeout on blocking socket operations. The value argument can be a nonnegative float expressing seconds, or None. If a float is given, subsequent socket operations will raise an timeout exception if the timeout period value has elapsed before the operation has completed. Setting a timeout of None disables timeouts on socket operations. s.settimeout(0.0) is equivalent tos.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1). New in version 2.3. • gettimeout()Return the timeout in floating seconds associated with socket operations, or None if no timeout is set. This reflects the last call tosetblocking() or settimeout(). New in version 2.3. 위와 같이 기본적으로는 blocking 모드이다. non-blocking mode를 이용하려면 setblocking(flag)을 이용해 non- blocking mode 로 가거나 아니면 settimeout 을 이용해 non-blocking mode 로 전환하면 된다.

19. 위와 같이 socket 객체를 생성하고 gettimeout을 하면 처음에 아무 것도 볼 수 없음 blocking mode (default) 이므로 값이 무한대임을 의미 그 다음에 setblocking() 을 이용해 non-blocking mode로 변환한 후 gettimeout을 호출하면 0.0 이 나옴 non-blocking mode의 default time out value는 0.0 임

20. 위의 상황에서 생성된 socket 객체를 제거하고 다시 socket을 생성하면 default 이므로 blocking mode 임을 확인 (gettimeout) 여기서 setblocking 을 이용하지 않고 바로 settimeout 을 이용해도 원하는 timeout을 시간을 가진 non-blocking mode 로 변환되는 것을 확인

21. Example • 다음은 blocking mode 의 간단한 예제이다. Server 측 : localhost connection 이고 8000 port 를 binding 한 후 accept 함수를 호출해 client 와의 connection을 기다리고 있다.

22. • Client 측 : non-blocking mode 이고 timeout 이 3.5 초이 다. connect 을 통해 서버와 연결 된 후 non-blocking mode로 변환되고, recv 를 통해 3.5 초간 서버로부터의 데 이터 전송을 기다리다가 예외를 발생시킨다.

.

반응형
반응형

codecademy.com python 100% complete.



반응형
반응형

프로그래밍 언어 최근 순위 


http://www.tiobe.com/tiobe-index/


javascript 를 위주로 Python을  공부하며 Go에 관심을 가져야 하는 것이라고. 




더 큰 그림을 보려면 수십 년 전의 톱 10 프로그래밍 언어의 위치를 아래에서 찾으십시오. 이들은 12 개월 동안의 평균 포지션입니다.





.

반응형
반응형
[에디터] Atom 에디터 https://atom.io/

 

Atom is a text editor that's modern, approachable, yet hackable to the core—a tool you can customize to do anything but also use productively without ever touching a config file.

 

 

* 아톰에디터에 해당되는 블로그 글

 

 

 

반응형
반응형

문자열을 반복하여 붙이는 3가지 코딩 방법 및 수행 시간 비교


[코드 1]
import time
start_time = time.time()
s = ''
for k in range(1000000):
    s += 'python'
end_time = time.time()
print end_time - start_time

출력: 0.243875980377

[코드 2]
start_time = time.time()
t = []
for k in range(1000000):
    t.append('python')
s = ''.join(t)
end_time = time.time()
print end_time - start_time

출력: 0.161774158478

[코드 3]
start_time = time.time()
s = 'python' * 1000000
end_time = time.time()
print end_time - start_time

출력: 0.000773191452026

위 결과로 알 수 있듯이 단순하게 문자열을 반복하여 붙이는 코딩 방법은 3번째 방식의 효율이 가장 좋습니다.

 

 

파이썬 온라인 코딩 학습 사이트 추천

 

https://www.codecademy.com/ko/tracks/python-ko 


온라인 코딩 학습 사이트로 유명한 codecademy의 Python 학습 컨텐츠입니다. 

한글로 친절하게 번역이 잘 되어 있으며, 

각 단계별로 실제 코딩을 하여야 다음 단계로 넘어갈 수 있기 때문에 

파이썬을 학습하기에 아주 좋은 사이트입니다.

 

 

파이썬으로 개발된 유명한 S/W에는 어떤 것이 있을까요?
아래 링크에서 확인할 수 있습니다.


위 링크의 내용에 나와 있듯이 Youtube도 Python으로 개발되었습니다.

 

 

 

반응형

+ Recent posts