기본 콘텐츠로 건너뛰기

추천 게시물

[Go] 고루틴

런타임(Runtime) visual code에서 브라우저 실행 단축키: Alt+B Go runtime은 메모리 관리, 가비지 수집, 동시성을 포함하여 Go 프로그림의 실행을 관리하는 역할을 합니다. 이 문서에서는 Go runtime을 자세히 살펴보고 아키텍초, 특성과 장점을 살펴봅니다. Go Runtime Architecture Go runtime은 모듈식이고 유연하게 설계되었으며 개발자가 특정 요구사항에 따라 동작을 사용자 정의할 수 있는 계층적 아키텍쳐를 갖추고 있습니다. 런타임은 스케줄러(schedualer), 가비지 수집기(garbage collector), 메모리 할당자(memory alllocator) 및 스택관리(stack management)를 포함한 어려 핵심 구성 요소로 구성됩니다. Schedualer Go 런타임의 핵심은 고루틴의 실행을 관리하는 스케줄러입니다. 고루틴은 효율적인 동시성을 가능하게 하는 가벼운 스레드입니다. 스케줄러는 사용 가능한 스레드에 고루틴을 분산하고, 스레드 로컬 스토리지를 관리하고, I/O 작업을 조정하는 역할을 합니다. thread(스레드): 프로그램 내에서 실행되는 흐름의 단위로 동시에 여러 작업이나 프로그램을 실행하는 것입니다. 즉, 코드를 실행할 수 있는 각 단위를 스레드라고 합니다. 고루틴(goroutine): Go 언어로 동시에 실행되는 모든 활동을 의미합니다. 고루틴을 만드는 비용을 스레드에 비해 매우 적기 떄문에 경량 스레드라고 합니다. 모든 프로그램은 적어도 하나의 main() 함수라는 고루틴을 포함하고 고루틴은 항상 백그라운드에서 작동합니다. 메인함수가 종료되면 모든 고루틴은 종료됩니다. 그러므로 고루틴보다 main이 먼저 종료되는 것을 방지해야 합니다. Go 스케줄러는 매우 효율적이고 확장 가능하도록 설계되어 많은 수의 동시 고루틴을 손쉽게 처리할 수 있습니다. 스레드 간에 부하를 분산하여 경합을 최소화하고 성능을 개선하는 작업 훔치기 알고리즘을 사용합니다...

통계 vs 기계학습

통계는 수치 데이터의 수집, 분석, 해석, 표현 및 구성을 다루는 수학의 한 분야입니다. 통계는 주로 두 가지 하위 분기로 분류됩니다. 기술 통계: 연속 데이터 유형(예: 연령)에 대한 평균, 표준 편차와 같은 데이터를 요약하는 데 사용되는 반면 빈도 및 백분율은 범주형 데이터(예: 성별)에 유용합니다. 추론 통계: 많은 경우 전체 데이터(통계 방법론에서 모집단이라고도 함)의 수집이 불가능하므로 데이터 포인트의 하위 집합(샘플이라고도 함)이 수집되고 전체 모집단에 대한 결론이 도출됩니다. 추론 통계로 알려져 있습니다. 추론은 가설 테스트, 수치적 특성 추정, 데이터 내 관계의 상관 관계 등을 사용하여 도출됩니다. 통계 모델링은 데이터에 대한 통계를 적용하여 변수의 중요성을 분석하여 숨겨진 숨겨진 관계를 찾는 것입니다. Machine Learning 머신 러닝은 과거 경험을 활용하여 미래의 결정을 내리기 위해 학습하고 지식을 사용하는 컴퓨터 과학의 한 분야입니다. 기계 학습은 컴퓨터 과학, 엔지니어링 및 통계의 교차점에 있습니다. 기계 학습의 목표는 감지 가능한 패턴을 일반화하거나 주어진 예제에서 알 수 없는 규칙을 만드는 것입니다. 기계 학습 환경의 개요는 다음과 같습니다. 기계 학습은 크게 세 가지 범주로 분류되지만 상황에 따라 이러한 범주를 결합하여 특정 응용 프로그램에 대해 원하는 결과를 얻을 수 있습니다. 지도 학습: 이것은 기계가 다른 변수와 대상 변수 간의 관계를 학습하도록 가르치는 것입니다. 교사가 학생들에게 자신의 수행에 대한 피드백을 제공하는 방식입니다. 지도 학습의 주요 부분은 다음과 같습니다. 분류 문제, 회귀 문제 비지도 학습: 비지도 학습에서 알고리즘은 감독 없이 또는 제공되는 대상 변수 없이 스스로 학습합니다. 주어진 데이터에서 숨겨진 패턴과 관계를 찾는 문제입니다. 비지도 학습의 범주는 다음과 같습니다. 차원 축소, 클러스터링 강화 학습: 이를 통해 기계 또는 에이전트가 환경의 피드백을 기반으로 행동을 학습할 수 있...

[python]KeyWord

keywords Characters or strings already used to define basic commands in programming languages such as python are called reserved words. This reserved word cannot be used when defining objects such as variables, functions, and classes when coding by the user. python has 33 reserved words, and it distinguishes between lowercase and uppercase letters in Engolsh. All other keywords are lowercase except True, False, None, etc. a and, as, assert, async, await b break c class, continue d def, del e eolf, else, except f False, finally, for, from g global i in, if, import, is l lambda n nonlocal, None, not o or r raise, return p pass ...

[kotlin]Smart Cast & Any type in Kotlin

Smart Cast In Kotlin, data types have the following meanings: 1) Define the size in which the object is stored 2) Whether objects are replaced or not. That is, they must have the same data type to execute. For example, the operation of Int type and Double type is not performed. val a: Int = 17 val b: Double= a println(b)      error: type mismatch: inferred type is Int but Double was expected                   val b: Double= a The assignment of a to object b is not done because the data types of objects a and b are different. When using a data type to which a smart cast is applied, the data type is specified according to the assigned value. The Number type is a data type to which a representative smart cast for numbers is applied. Therefore, if the Number type is applied in the above case, it is as follows. val a: Int = 17 val b: Number=a println(b)      17 In the code above, a is o...

Primitive and Reference type on kotlin

The Comparison between two objects  Comparison uses double equal sign (==) and triple equal sign (===) Double equal sign (==): Compares values. Triple equal sign (===): Compares the reference address. Kotlin's data type is basically a reference type, and basic data types such as Int and Double are converted at the compile stage. val a: Int = 128 val b: Int = 128 println(a == b)      true //Two objects have the same value. println(a === b)      true After compilation, both objects a and b are converted to primitives and stored in stack memory. Therefore, their storage locations are the same. val a: Int = 128 val c: Int? = 128 println(a == c)      true println(a === c)      false The data types of the two objects a and c above are Int and nullable Int, respectively. In the compilation phase, Int is converted to primitive type, but nullable Int remains as reference type. Therefore, Int is stored in s...

How to get solution of linear system?

$$\text{A}\overrightarrow{x}=\overrightarrow{b}\qquad \text{Eq.1}$$ A: m $\times$ n Matrix, Coefficient(Standard) Matrix x: Variable vector(column vector) b: Constant vector(column vector) Equation 1 is called a matrix equation or a linear combination system. The above relationship means that an appropriate solution exists. The solution of the matrix equation can be calculated by using the inverse matrix and by using the row echelon form matrix (RREF). 1. How to use inverse matrix Invertible matrix: matrix (M) in which the inverse matrix exists The basic conditions of this invertible matrix are as follows. 1) square matrix (number of rows = number of columns) 2) The determinant is not zero. $$det(M) \neq 0$$ The inverse matrix of the square matrix M is denoted by  $M^{-1}$ , and the product of these two matrices is the identity matrix (I). An identity matrix: a matrix with diagonal elements of 1 and all other elements of 0 >>> I2=np.eye(2);I2...

Linear combination

$R_n = \{\overrightarrow {v_1}, \overrightarrow {v_2}, ...., \overrightarrow {v_n}\}$ $\text{scalar} \; c=\{c_1, c_2,..., c_n\}$ For vector R and scalar c, if the following relationship Equation 7 is defined $$y=c_1 \overrightarrow {v_1} + c_2 \overrightarrow {v_2} + .... +c_n \overrightarrow {v_n},$$ This is called the linear combination of the vector R and the scalar (weight). 1. Are linear combinations in vectors a 1 , a 2 and vector b? Whether the relationship is established, $$x_1 a_1 +x_2 a_2 = b \quad x_1, x_2 : scalar(weight)$$ $$a_1 =\left[\begin{array}{r}1\\-2\\-5 \end{array}\right], \qquad a_2=\left[\begin{array}{r}2\\5\\6 \end{array}\right], \qquad b=\left[\begin{array}{r}7\\4\\3\end{array}\right]$$ $$x_1 \left[\begin{array}{r}1\\-2\\-5 \end{array}\right] + x_2 =a_2=\left[\begin{array}{r}2\\5\\6 \end{array}\right]=\left[\begin{array}{r}7\\4\\3\end{array}\right]$$ The above is arranged in the form of matrix product as follows. $$\left[\begin{array}{r}1&...

pivot position in rref

pivot position In matrix A, the pivot position is the position corresponding to leading 1 in the row echelon form matrix (rref) of the matrix. A pivot column is a column that contains a pivot position. The rref of matrix A is ? >>> from sympy import * >>> A=Matrix([[0, -3, -6,4, 9],[-1,-2,-1, 3, 1], [-2, -3, 0, 3, -1], [1, 4, 5, -9, -7]]) >>> A Matrix([ [ 0, -3, -6,  4,  9], [-1, -2, -1,  3,  1], [-2, -3,  0,  3, -1], [ 1,  4,  5, -9, -7]]) >>> A.rref() (Matrix([ [1, 0, -3, 0,  5], [0, 1,  2, 0, -3], [0, 0,  0, 1,  0], [0, 0,  0, 0,  0]]), (0, 1, 3)) In that rref, the columns containing the leading 1 are 1, 2, and 4 columns. $$\left[\begin{array}{rrrrr}1(pivot)&0&-3&0&5\\0&1(pivot)&2&0&-3\\0&0&0&1(pivot)&0 \\0&0&0&0&0\end{array}\right]$$ >>> from sympy import * >>> B=Matrix...