tf.keras.layers.Conv2D() 행렬 형태의 데이터를 filter가 convolution 작업을 하는 function. arguments 설명 filters : integer, 연산 후 나오는 공간의 차원 즉, output convolution 의 filter 개수.…
numpy 라이브러리를 사용한 broad casting 및 vector, dotproduct, multiplication matrix 를 python 코드로 구현한 것: ReLU 함수 구현 :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def naive_relu(x): assert len(x.shape) == 2 x = x.copy() for i in range(x.shape[0]): for j in range(x.shape[1]): x[i,j] = max(x[i,j], 0) return x a = np.array([[1,2,-2,4,5], [1,-1,3,-4,5]]) a = naive_relu(a) print(a) |
행렬덧셈 :…
Tensorflow 에서 복잡한 신경망에서 효율적이고 깔끔한 구현 방법 중 사용되는 중요한 함수다. 변수이름의 낭비를 막는 방법 tf.get_variable 매개변수: 그 중 현재 수준에서 사용하는 매개변수 …
python 함수로 has attribute : 속성을 갖고있나? get attribute : 속성을 가져와 set attribute : 속성을 세팅, 변경
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
class A: a = 1 def b(self): pass print("A class에 b 가 있나?",hasattr(A,'b')) print("A class에 c 가 있나?",hasattr(A,'c')) print("A class에 a의 값이 뭔가?",getattr(A,'a')) print("A class에 a의 값에 4를 넣어") setattr(A,'a',4) print("A class에 a의 값은 뭔가?",getattr(A,'a')) |
|
1 2 |
A.a = 7 print("A class에 a의 값은 뭔가?",getattr(A,'a')) |
이와 같이 setattr 를…
텐서플로우의 기본이 되는 함수 tf.constant(value, dtype=None, shape=None,name=’Const’, verify_shape=False) 상수 텐서를 만드는 함수. value 에 넣은 값이 채워지며 상수값, 또는 유형 값을 넣을 수 있다.…
tf.assign(ref, value, validate_shape=None, use_locking=None, name=None) ref 값이 value 값을 대입으로 받아 업데이트된 ref값을 반환. 값이 할당 된 후 ref 의 새 값을 보유하는 Tensor를 출력한다.…
np.c_[] 함수는 데이터에 새로운 데이터 열을 추가 np.r_[] 함수는 데이터에 새로운 데이터 행을 추가
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
print(housing.target.reshape(-1,1).shape) x = np.array([[1,1,1,1], [2,2,2,2], [3,3,3,3]]) print("원래 데이터:\n",x) x_c = np.c_[x,np.ones((3,1))] print("끝열에1을 추가:\n",x_c) x_c = np.c_[np.ones((3,1)),x] print("첫열에1을 추가:\n",x_c) x_r = np.r_[x,np.ones((1,4))] print("끝행에1을 추가:\n",x_r) x_r = np.r_[np.ones((1,4)),x] print("첫행에1을 추가:\n",x_r) |
numpy.reshape np.reshape(a, newshape, order=’C’) 데이터를 변경하지 않고 배열에 새로운…
sklearn에서 제공하는 전처리 함수라이브러리인 preprocessing에서 scale 과 StandardScaler 함수에 대해 알아본다. 먼저 scale 함수 preprocessing.scale(X, axis = 0, with_mean=True, with_std=True, copy=True) 매개변수 : X…