05-02 08:47
Recent Posts
Recent Comments
관리 메뉴

너와나의 관심사

NLP 자연어 스터디를 위한 python tutorial 본문

카테고리 없음

NLP 자연어 스터디를 위한 python tutorial

벤치마킹 2019. 1. 20. 16:51

python study 1일차 

d = {'baby': 2, 'dog': 4, 'spider': 8}

for test in d:

    legs = d[test]

    print('A %s has blabla %d legs'  % (test,legs ))


A person has 2 legs
A cat has 4 legs
A spider has 8 legs


튜플 추가 

 a = (1, 2, 3)

 a = a + (4, ) 

 print(a) 

 (1, 2, 3, 4)

list 추가

 list1 = [1,2,3]

 list1.append(4)

[1, 2, 3, 4]


numpy 에서 행렬의 곱을 구하는 방법

import numpy as np a = np.zeros((2,2)) # Create an array of all zeros print(a) # Prints "[[ 0. 0.] # [ 0. 0.]]" b = np.ones((1,2)) # Create an array of all ones print(b) # Prints "[[ 1. 1.]]" c = np.full((2,2), 7) # Create a constant array print(c) # Prints "[[ 7. 7.] # [ 7. 7.]]" d = np.eye(2) # Create a 2x2 identity matrix print(d) # Prints "[[ 1. 0.] # [ 0. 1.]]" e = np.random.random((2,2)) # Create an array filled with random values print(e) # Might print "[[ 0.91940167 0.08143941] # [ 0.68744134 0.87236687]]"


print("numpy.matmul(c,d) =\n", np.matmul(c,d))


print("numpy.matmul(c,d) =\n", np.matmul(c,d))


 



Comments