반응형
SPARK를 사용하여 대용량 데이터셋의 평균과 표준편차 구하기
Deep Learning & Machine Learning/강좌&예제 코드2021. 12. 12. 12:39SPARK를 사용하여 대용량 데이터셋의 평균과 표준편차 구하기

메모리에 한번에 올리기 힘든 데이터셋에 표준화(standardization)를 적용하기 위해 평균 및 표준 편차를 계산하기 위해 사용한 방법입니다. 2021. 12. 12 최초작성 1. JDK가 필요합니다. 안드로이드 스튜디오를 사용중이라면 이미 OpenJDK가 설치되어 있으므로 바로 4번을 확인해보세요. 아래 링크에서 11 GA 윈도우 버전을 다운로드합니다. https://jdk.java.net/archive/ 2. 압축을 풀은 후, jdk-11 폴더를 C:\에 복사합니다. 3. 윈도우 키 + R을 누른 후, sysdm.cpl를 실행하여 시스템 환경 변수 path에 아래 경로를 추가합니다. C:\jdk-11\bin 4. 명령 프롬프트에서 java 실행 가능 여부를 확인합니다. C:\Users\webna..

Deep Learning & Machine Learning/강좌&예제 코드2021. 12. 11. 07:32tensorflow dataset에서 batch 단위로 window 적용하기

tensorflow dataset을 크기 10인 batch로 나눈 다음 각 batch에 대해 크기 3 window를 적용한 예제입니다. 2021. 12. 11 최초작성 import tensorflow as tf import numpy as np ds= tf.data.Dataset.range(120) size = len(ds) print('size', size) print('\n\n') num_of_samples = len(ds) window_size = 3 stride_size = 1 for i,sample in enumerate(ds.batch(10)): print(sample.numpy()) print() dataset = tf.data.Dataset.from_tensor_slices(sample) ..

Deep Learning & Machine Learning/강좌&예제 코드2021. 12. 8. 21:43Tensorflow Dataset 일부만 사용하기

Tensorflow Dataset의 일부만 사용하는 예제입니다. 2021. 12. 6 - 최초작성 2021. 12. 8 - 최종작성 import tensorflow_datasets as tfds # tensorflow dataset 'minst'의 train과 test를 각각 전체를 사용합니다. ds = tfds.load('mnist', split=['train', 'test']) print(len(ds[0]), len(ds[1])) # tensorflow dataset 'minst'의 train과 test를 각각 10%씩 사용합니다. ds = tfds.load('mnist', split=['train[:10%]', 'test[:10%]']) print(len(ds[0]), len(ds[1])) # te..

Deep Learning & Machine Learning/강좌&예제 코드2021. 12. 1. 21:56Tensorflow 학습 코드를 두 개를 동시에 실행하는 경우 model.fit에서 에러

Tensorflow 학습 코드를 두개 동시에 실행하는 경우 model.fit에서 다음과 같은 에러가 나서 나중에 실행한 코드는 중단됩니다. tensorflow.python.framework.errors_impl.InternalError: Attempting to perform BLAS operation using StreamExecutor without BLAS support 2021. 12. 1 최초작성 다음 링크에서 가져온 다음 코드를 추가하면 Tensorflow 학습 코드 두개를 동시에 실행해도 에러가 나지 않습니다. 하지만 GPU 메모리 크기에 따라 실행에 문제가 생길 수 있습니다. https://github.com/tensorflow/tensorflow/issues/11812 import ten..

Tensorflow - tf.data.Dataset.from_generator 예제
Deep Learning & Machine Learning/강좌&예제 코드2021. 11. 19. 21:32Tensorflow - tf.data.Dataset.from_generator 예제

모델에 데이터를 공급하는 방식 중 하나인 tf.data.Dataset.from_generator를 살펴봅니다. 데이터가 너무 커서 메모리에 모두 로드할 수 없는 경우 데이터를 한번에 모두 읽어오는 대신에 디스크에서 데이터를 배치(batch) 단위로 로드하도록 할 수 있습니다. 2021. 11. 19 최초작성 tf.data.Dataset.from_generator 우선 모델이 필요로 하는 데이터를 생성하는 generator 함수가 필요합니다. 이 함수는 return 문 대신에 yield 문을 사용합니다. 여기에서 데이터셋은 28 x 28 크기의 이미지와 10개의 클래스 중 하나임을 나타내는 정수 쌍으로 구성된 1000개의 데이터라고 가정합니다. generator 함수에서 다음처럼 가상의 데이터를 생성하여 ..

텐서플로우 콜백함수( Tensorflow Callbacks ) - ModelCheckpoint, ReduceLROnPlateau, EarlyStopping
Deep Learning & Machine Learning/강좌&예제 코드2021. 11. 17. 21:48텐서플로우 콜백함수( Tensorflow Callbacks ) - ModelCheckpoint, ReduceLROnPlateau, EarlyStopping

텐서플로우 콜백함수 ModelCheckpoint, ReduceLROnPlateau, EarlyStopping를 다루고 있습니다. 2021. 11. 17 최초작성 ModelCheckpoint 모델 또는 가중치를 저장할 때 사용되는 콜백함수입니다. www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint 인자 설명 filepath 모델 파일을 저장할 경로를 입력합니다. 충돌이 나지 않도록 하기 위해 다른 콜백 함수에서 여기에서 지정한 경로를 사용하면 안됩니다. monitor 콜백함수에서 모델을 저장할때 기준이 되는 값을 지정합니다. loss, val_loss, accuracy, val_accuracy등을 지정할 수 있습니다. 보통 Model..

Deep Learning & Machine Learning/강좌&예제 코드2021. 11. 12. 23:07tfds build 시 에러 AssertionError: Unrecognized instruction format ( 또는 Unrecognized split format )

tfds build시 발생한 AssertionError: Unrecognized instruction format (또는 Unrecognized split format ) 원인과 해결방법입니다. 2021. 11. 12 최초작성 File "/home/webnautes/miniconda3/envs/tensorflow/lib/python3.7/site-packages/tensorflow_datasets/core/tfrecords_reader.py", line 519, in _str_to_relative_instruction raise AssertionError('Unrecognized instruction format: %s' % spec) AssertionError: Unrecognized instructi..

Deep Learning & Machine Learning/강좌&예제 코드2021. 9. 14. 22:32Tensorflow 디버깅 정보 메시지 안보이게 하기

Tensorflow 모듈을 사용할 경우 사용자가 출력하지 않은 추가 정보들이 많이 출력됩니다. 특히 CUDA를 Tensorflow 모듈에서 사용하는 경우 더 많이 출력됩니다. 2021. 9. 14 최초작성 다음 링크에서 소개하는 방법 중 하나를 적용하면 이 디버깅 정보 메시지를 안보이게 할 수 있습니다. https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information 예를 들어 다음처럼 tensorflow 모듈만 임포트했는데도 CUDA 관련 메시지가 추가로 출력됩니다. C:\Users\webnautes>python Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:..

Deep Learning & Machine Learning/강좌&예제 코드2021. 9. 14. 22:18Tensorflow Dataset의 window 메소드 사용법

Tensorflow Dataset의 window 메소드 사용법을 파악해보려고 테스트해 본 내용입니다. 2021. 9. 14 - 최초작성 range 메소드를 사용하여 0 ~ 9 까지 값을 갖는 Dataset을 생성합니다. as_numpy_iterator 메소드는 Dataset의 모든 요소를 numpy로 변환하는 iterator를 리턴하는데 이것을 리스트에 담아서 출력할 수 있습니다. import tensorflow as tf ds = tf.data.Dataset.range(10) print(list(ds.as_numpy_iterator())) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 첫번째 window 예제 window 메소드는 원본 Dataset의 요소를 3개씩 묶어서 서브 Dataset을..

Deep Learning & Machine Learning/강좌&예제 코드2021. 9. 9. 20:22LSTM 레이어 사용시 cuDNN 관련 에러 나는 경우 해결방법

구글에서 검색해봐도 해결방법이 보이지 않았던 에러입니다. 원인이 여러가지 일 수 있겠지만 Keras의 LSTM 레이어에 activation='relu'를 추가해놓았다면 제거해주면 해결됩니다. WARNING:tensorflow:Layer lstm will not use cuDNN kernels since it doesn't meet the criteria. It will use a generic GPU kernel as fallback when running on GPU.

반응형
image