⇒ linear line of h(x) is converted to a single point in cost function graph
Gradient Descent Algorithm
Gradient Descent Algorithm Contour Plot
If is α too small ⇒ gradient descent can be slow (alpha = step size)
If is α too big ⇒ gradient descent fail to converge, or even diverge
α rate doesn’t need to decrease →automatically take smaller steps
Batch Gradient Descent: every step needs to calculate all training sets in batches
Review:
Although there is difficulty in understanding the whole process, particularly the gradient descent equation, I am fairly able to get the big picture and the important concepts of machine learning regarding supervised/unsupervised learning, model representation, cost function, and gradient descent algorithm.
I am currently able to follow the contents and able to solve the quiz in Coursera for each lecture without much difficulty, yet!
Span: set of all linear combinations of the vectors (기본변형으로만들수있는모든벡터들)
Linear combination을통한 matrix multiplication의 inner product & outer product 계산방법존재
Linearly independent: only one solution (trivial solution)
Linearly dependent: other nontrivial solutions / linearly dependent set produces multiple possible linear combinations.
Subspace: a subset of R^n closed under linear combination
==> a subspace is always represented as Span{v1, …, vp}
Basis of a subspace: set of vectors that satisfies (1) fully spans the given subspace H (2)linearly independent
•eg. H = Span{v1, v2, v3} è Span{v1, v2} forms a plane, but v3=2v1+3v2 ∈Span{v1, v2} è {v1, v2} is a basis of H, but not {v1, v2, v3} nor {v1} is a basis.
class Student(object): # 클래스 선언부 (예약어 - 클래스 이름 - 부모 클래스)
SCHOOL = 'GOORM' # 클래스 속성 (Class attribute)
def __init__(self, name: str, sid: int): # 생성자 (현재 수정하고자 하는 객체=self)
self.name = name # 속성 (Attribute)
self.sid = sid
self.classes = set()
# 클래스 함수 (Method)
def take_class(self, class_name: str) -> None:
self.classes.add(class_name)
def drop_class(self, class_name: str) -> None:
self.classes.discard(class_name)
# 클래스 생성
gildong_hong = Student('Gildong Hong', 20224352)
# 속성 출력
printgildong_hong.name, "in", Student.SCHOOL)
# 메소드 실행
gildong_hong.take_class("CS101")
gildong_hong.take_class("CS202")
gildong_hong.drop_class("CS101")
# 출력 결과
# Gildong Hong in GOORM
Magic Method (매직 메소드)
(cf) __init__, __call__, ___length__, __getitem__ 을 많이 사용함
#context manager
class Student:
def __init__(self, name, sid):
self.name = name
self.sid = sid
def __enter__(self): # with 구문에 들어갈 때 사용, return 값이 as 이하로 할당
self.classes = set()
return self
def __exit__(self, exc_type, exc_value, trace): # with 구문 나갈 때 사용
self.classes.clear()
gildong_hong = Student("Gildong Hong", 20224372)
with gildong_hong:
gildong_hong.classes.add('CS201')
with Student("Gildong Hong", 20224372) as gildong_hong:
gildong_hong.classes.add('CS201')
print(gildong_hong.name, gildong_hong.sid) # Gildong Hong 20224372