tensorflow

    [Math] Cartesian Product (or Descartes Product, Product Set)

    Cartesian Product (or Descartes Product) 공집합(empty set, null set)이 아닌 여러 sets를 이용하여 새로운 set을 만드는 연산. Cartesian product는 operand인 여러 집합들의 각 elements를 원소(component, element)로 하는 tuple을 element(원소)로 하는 set을 반환함. 2개의 집합 $A$, $B$의 Cartesian product $A\times B$는 다음과 같음. $$A\times B= \{ (a,b) | a \in A, b\in B\}$$ $n$ 개의 집합 $A_1, A_2, \dots, A_n$의 Cartesian Product는 다음과 같이 정의됨. $$\displaystyle \prod^n_..

    [Keras] 현재의 Learning Rate를 확인하는 Custom Callback

    Adagrad 이후의 Adam등에서는 Adaptive Learning Rate가 적용되면서 간단하게 하나의 Learning rate 값이 아닌 Weight에 따라 다른 속도로 decay되는 처리가 이루어진다. 하지만 초기에 준 inital value에 해당하는 Learning rate를 기반으로 전체적으로 적용되는 Learning rate가 있고, 여기에 이전 epoch들에서의 gradient의 변화 정도 등을 고려한 처리가 이루어지기 때문에 현재 epoch에서의 일종의 decayed learning rate가 존재한다고 봐도 된다. 예전의 Keras의 경우엔 optimizer.lr 등으로 현재의 learning rate를 구해왔으나, decay factor에 의해 epoch마다 값이 달라진 learni..

    [NumPy] Broadcasting

    ndarray와 scalar를 연산시킬때, scalar를 상대 ndarray와 같은 shape이면서 해당 scalar의 값을 가진 ndarray로 변경시키고나서 이 scalar로부터 만들어진 ndarray와 상대 ndarray를 동작시키는 방식으로 elementwise연산이 수행되는 기능. 주의할 것은 scalar 를 확장시키는 것이 기본이라는 점임. PyTorch나 TensorFlow의 텐서도 같은 방식으로 broadcasting이 수행된다. 이를 정리하면 다음과 같은 Rule에 따른다고 생각할 수 있음. Rules of Broadcasting Rule 1 두 ndarray의 차원의 수(number of dimensions)가 같지 않을 경우, 적은 ndarray의 shape가 leading side쪽..

    [LA] tf.linalg.solve 로 linear system 의 solution 구하기.

    David C. Lay의 Linear Algebra의 1장의 예제를 tensorflow로 확인. colab으로 간단히 확인 가능함. import tensorflow as tf import numpy as np A = np.array([ [1 ,-2, 1], [0 , 2,-8], [-4, 5, 9] ], dtype=float) cmtx = tf.constant(A) b = np.array([0,8,-9],dtype=float) # tf.constant 를 이용. (1) # b = b.reshape(-1,1) # bvec = tf.constant(b) # tf.constant 를 이용. (2) bvec = tf.constant(b, shape=(3,1)) # tf.Varialbe을 이용. # b = b.re..

    [ML] WSL2 : Install Tensorflow (GPU)

    wsl2부터는 gpu 사용가능함: cuda 가능! tensorflow 가 제대로 GPU지원. DirectML을 통해서 GPU지원도 가능하지만, 아직까지는 CUDA가 나은 편임. Pre-requirements 1. Windows 11 (>=20150) winver 을 수행하여, build 가 20150 이상이어야 WSL2에 cuda 설치가 가능 2. WSL2를 지원하는 NVIDIA Driver 설치. 그래픽 카드 종류 미리 확인할 것. 2022.03.10 - [Computer/ETC] - HWiNFO : PC의 HW 사양 정보 확인 SW HWiNFO : PC의 HW 사양 정보 확인 SW Windows OS에서 PC의 HW구성 상태를 확인해보기 가장 좋은 SW임. 여러 컴퓨터를 사용하는 경우, HW구성을 외..