목록전체 글 (64)
코딩걸음마
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/eT8EZp/btrFzwdxW05/DfZzAl0Fq15Jx3V52JGBH1/img.png)
1. Pytorch의 Tensor Allocation import torch #실수 tensor 생성 ft = torch.FloatTensor([[1, 2], [3, 4]]) #정수 tensor 생성 lt = torch.LongTensor([[1, 2], [3, 4]]) #byte tensor 생성 (0과 1로 구성) bt = torch.ByteTensor([[1, 0], [0, 1]]) #garbage tensor 임의의 값을 포함하는(실수) 텐서 생성 x = torch.FloatTensor(10, 5) #(행, 열) output------------------------------------------------------------ #tensor([[2.7444e+20, 2.8298e+20, 1.1..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/EmkID/btrFyKP1Q47/FjwTbKG9SG8gq7PzaQLGGk/img.png)
딥러닝에 사용되는 모듈로 대표적으로 Tensorflow, keras, Pytorch가 있다. https://pytorch.org/get-started/locally/ PyTorch An open source machine learning framework that accelerates the path from research prototyping to production deployment. pytorch.org Pytorch는 numpy와의 호환성이 좋으며 사용이 편리하다는 장점이 있다. (물론 홈페이지도 깔끔하다..) 위 링크에 들어가서 자신의 조건에 맞게 선택하고, Run this Commend에 나온 문장을 anaconda powershell (window)이나 터미널(맥)에 입력하면 설치가 시작..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/b1oVsO/btrFoE4SEq4/d0u3bkcBlz6qrEWpT3wOR1/img.gif)
데이터프레임(DataFrame) 메모리 줄이는 코드! 캐글에서 가장 인기있는 코드이다. 불러오는 파일의 크기가 300mb이상이고, numeric정보만 있다면 사용할 때 메모리 감소 효과가 크다 dtype 변경에 따라 일부 모듈에서 오류를 낼 수 있지만, 그때마다 astype으로 교체해주는 귀찮음보다 메모리감소 효과가 너무 크다. def reduce_mem_usage(df): """ iterate through all the columns of a dataframe and modify the data type to reduce memory usage. """ #start_mem = df.memory_usage().sum() / 1024**2 #print('Memory usage of dataframe is..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/MHUcY/btrFopGFoKh/0JFl0rEJviKVLCR35sKNWk/img.png)
재귀 함수(Recursive Function)란 자기 자신을 다시 호출하는 함수를 뜻한다. - 재귀 함수는 함수의 종료 조건을 반드시 명시해야 한다. - 종료 조건을 제대로 명시하지 않으면 함수가 무한히 호출된다. def hello(n): print("반갑습니다") if n==0: return else: return hello(n-1) 최소공배수 def gcb(a,b): return a if b==0 else gcb(b,a%b) 최대공약수 (유클리드 호재법) def max(n,m): if m>n : m,n = n,m while m != 0 : n = n%m n,m = m,n return n def min(n,m): return n*m // max(n,m) 피보나치수열 def factorial(n): if..