분류 전체보기(852)
-
tensorflow 폴더 생성 및 지우기
if tf.gfile.Exists(model_dir): tf.gfile.DeleteRecursively(model_dir) tf.gfile.MakeDirs(model_dir) tf.gfile.MakeDirs(model_dir + "/save_model") tf.gfile.MakeDirs(vis_dir) tf.gfile.MakeDirs(board_dir) else : tf.gfile.MakeDirs(model_dir) tf.gfile.MakeDirs(model_dir + "/save_model") tf.gfile.MakeDirs(vis_dir) tf.gfile.MakeDirs(board_dir)
2019.05.28 -
GAN minibatch discrimination code
NUM_KERNELS = 5 def minibatch(input, num_kernels=NUM_KERNELS, kernel_dim=3, name = None ): output_dim = num_kernels*kernel_dim w = tf.get_variable("Weight_minibatch_" + name , [input.get_shape()[1], output_dim ], initializer=tf.random_normal_initializer(stddev=0.2)) b = tf.get_variable("Bias_minibatch_" + name , [output_dim],initializer=tf.constant_initializer(0.0)) x = tf.matmul(input, w) + b a..
2019.05.28 -
[변수 생성]Structured Data에서 CNN을 활용한 새로운 변수 생성하기
일단 빠르게 분석을 해야 되면, 일반 전처리는 다해보고 모델링해서 돌려본다. 근데 먼가 결과가 신통방통하지 못하다. 이땐 머 hyperparamter를 최적화해도 결과는 영 그럴 것이다. 그러면 여기서부터 고민을 하게 된다. 일단 그림을 변수별로도 열심히 그려봐서 딱 구분되는 것이 있는지 살펴보거나, Correlation을 구해본다. 사실 여기서 머 추가적으로 분포를 본다고 해도 이미 모델링해서 잘 나오지 않았다면, 웬만하면 찾기 어려울 것이다. 그렇다면 여기서 더 성능을 높이기 위해 유의미한 새로운 파생변수를 어떻게 만들어야 할까?? 일단 데이터가 자기 도메인이 아니게 되면 막막하다. 일단 자기가 주로 하던 분야가 아니니 생각의 깊이도 당연히 얕을 수밖에 없다. 현업에게 요청할 수도 있지만, 계속 붙잡..
2019.05.27 -
numpy.unique, numpy.searchsorted
카테고리를 정수로 변환하기! pandas에는 cat.codes가 있다. 유니크 범위 : ( 0 , 카레고리수 -1 ) from itertools import combinations possible_categories = list(map(lambda x: x[0] + x[1], list(combinations('abcdefghijklmn', 2)))) categories = np.random.choice(possible_categories, size=10000) print(categories) ['al' 'kl' 'jk' ... 'jm' 'bm' 'hj'] unique_categories, new_categories = np.unique(categories, return_inverse=True) print..
2019.05.26 -
Broadcasting, numpy.newaxis
numpy를 자주 쓰다 보면 사용하면 Broadcasting! https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html Broadcasting — NumPy v1.16 Manual Broadcasting Note See this article for illustrations of broadcasting concepts. The term broadcasting describes how numpy treats arrays with different shapes during arithmetic operations. Subject to certain constraints, the smaller array is “broadcast” acro docs.scip..
2019.05.26 -
numpy argsort
argsort를 이용해서 하나의 기준이 있을 때 다른 것도 쉽게 정렬할 수 있다! 만약 키와 나이가 쌍이 있다고 하자. ages = np.random.randint(low=30, high=60, size=10) heights = np.random.randint(low=150, high=210, size=10) print(ages) print(heights) ## ages : [56 53 52 54 42 53 39 37 50 57] ## heights : [189 182 158 204 187 168 155 169 206 153] 이것을 나이를 기준으로 height 도 같이 sort해보자! 이 방식은 zip(ages , heights) 보다 훨씬 빠르다고 합니다!! sorter = np.argsort(age..
2019.05.26 -
넘파이 좋은 팁이 많음!
http://arogozhnikov.github.io/2015/09/29/NumpyTipsAndTricks1.html Data manipulation with numpy: tips and tricks, part 1 also, since algebra is you friend, you can do it times faster: $$||x_i - x_j||^2 = ||x_i||^2 + ||x_j||^2 - 2 (x_i, x_j) $$ so dot products is the only thing you need. arogozhnikov.github.io
2019.05.25 -
Object Detection에서 Data Augumentation Tool 소개
https://blog.paperspace.com/data-augmentation-for-bounding-boxes/?fbclid=IwAR132UulElBLFflTPa8aF0S-zREgXr3rgh4SrGKelsds_Mld_S4MNt9a7xQ Data Augmentation For Bounding Boxes: Flipping How to adapt major image augmentation techniques for object detection purposes. We also cover the implementation of horizontal flip augmentation. blog.paperspace.com
2019.05.23 -
hidden layer 수와 Node를 몇개나 해야 할 지에 대한 글
https://stats.stackexchange.com/questions/181/how-to-choose-the-number-of-hidden-layers-and-nodes-in-a-feedforward-neural-netw?fbclid=IwAR3cWv4ULiZAQpAIyvRDY_KbgUT2G4g9BirZFUxI9Jho6uUHarqpqLgTQYk How to choose the number of hidden layers and nodes in a feedforward neural network? Is there a standard and accepted method for selecting the number of layers, and the number of nodes in each layer, in..
2019.05.23 -
LSTM AutoEncoder를 사용해서 희귀케이스 잡아내기
도움이 되셨다면, 광고 한번만 눌러주세요. 블로그 관리에 큰 힘이 됩니다 ^^ 우리 데이터는 많은데, 희귀 케이스는 적을 때 딥러닝 방법을 쓰고 싶을 때, AutoEncoder를 사용해서 희귀한 것에 대해서 탐지하는 방법론으로 대체한다고 한다. 이런 방법론을 써야지 노말한 데이터를 다 사용할 수 있으니 말이다. 이제는 만약에 내가 가진 데이터가 시계열성을 가진 데이터면 어떻게 해야 할까?? 기존 방식을 사용하게 되면 시간적인 변수를 고려하지 못하게 된다. 그러므로 이번에는 시간 부분도 고려해서 향상한 모델인 LSTM AutoEncoder 방법을 사용해보자. 1. 일단 LSTM을 위한 데이터 정제 2. 모델링 3. 희귀 케이스 어떻게 잡는지? 일단 LSTM이 뭘까? LSTM은 RNN의 일종으로써 , 타임 ..
2019.05.23 -
[TIP / Pandas] Pandas를 보다 올바르게 사용하는 방법
https://towardsdatascience.com/how-to-use-pandas-the-right-way-to-speed-up-your-code-4a19bd89926d How to use Pandas the RIGHT way to speed up your code The Pandas library has been a heavenly gift to the Data Science community. Ask any Data Scientist how they like to handle their datasets… towardsdatascience.com 원글을 참고하면 더욱 좋습니다. Pandas하면 파이썬에서 자주 사용하는 패키지인데요. 이것이 작은 데이터에서는 할만한데, 큰 데이터를 가끔 다룰 때는 ..
2019.05.23 -
[ Python ] UMAP (Uniform Manifold Approximation and Projection)
이것의 관심을 가진 이유는 원래 기본적인 T-SNE은 Visualization 용으로만 쓰는데, 실제로 이 패키지에서는 그 Embedding 한 것을 변수로 사용할 수 있다고 합니다. 그래서 train을 학습시켜서 그걸 다시 test에 transform 하는 식으로 변형도 가능하다고 해서, 일반적으로 우리가 알고 있는 T-SNE와는 달리, 저차원으로 잘 축소해서 사용할 수 있을 것 같아서 포스팅합니다.. https://arxiv.org/abs/1802.03426 https://github.com/lmcinnes/umap https://umap-learn.readthedocs.io/en/latest/parameters.html 제가 한번 해본건데요! 지금 이게 결국 feature로 쓸 수 있다면 KNN C..
2019.05.22