TensorFlow 5

Tensorflow : Dense로 이미지 분류

Dense로 이미지 분류 MNIST Dataset을 활용한다 https://sdc-james.gitbook.io/onebook/4.-and/5.1./5.1.3.-mnist-dataset 5.1.3. MNIST Dataset 소개 - OneBook(Python & Deep Learning) Label 은 이미지가 나타내는 숫자가 어떤 숫자인지를 나타내는 라벨 데이타로 10개의 숫자로 이루어진 1행 행렬이다. 0~9 순서로, 그 숫자이면 1 아니면 0으로 표현됩니다. 예를 들어 1인경우는 [0,1,0 sdc-james.gitbook.io import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # 데이터셋 (x_train, y_tr..

keras : 단순선형회귀 모델

import tensorflow as tf from keras.models import Sequential from keras.layers import Dense from keras import optimizers import numpy as np # x_data, y_data 설정하고 상관계수 확인 x_data = [1.,2.,3.,4.,5.] y_data = [1.2,2.0,3.0,3.5,5.5] print('상관계수 : ', np.corrcoef([x_data, y_data])) # 모델 입력, 컴파일 model = Sequential() model.add(Dense(units = 1, input_dim = 1, activation = 'linear' )) model.compile(optimizer..

Tensorflow : 단순선형회귀 모델

import tensorflow as tf import numpy as np opti = tf.keras.optimizers.SGD() # SGD를 사용하자. w = tf.Variable(tf.random.normal((1,))) # normal 튜플 값으로 준다 b = tf.Variable(tf.random.normal((1,))) # w, b 값 튜플로 받기 tf function 내용 : https://www.tensorflow.org/guide/function?hl=ko tf.function으로 성능 향상하기 | TensorFlow Core Google I/O는 끝입니다! TensorFlow 세션 확인하기 세션 보기 tf.function으로 성능 향상하기 Note: 이 문서는 텐서플로 커뮤니티에서 ..

Tensorflow 와 Keras

# 선형회귀 분석전 실습 cost를 최소화 하는 과정을 시각화 Keras를 사용하지 않고 Tensorflow만 사용했다. import tensorflow as tf import matplotlib.pyplot as plt x = [1,2,3,4,5] y = [2,4,6,8,10] b = 0 hypothesis = w * x + b ( w : weight, b : bias) w_val = [] cost_val = [] for i in range(-30, 50): feed_w = i * 0.1 # 0.1 은 학습률(learning rate) hypothesis = tf.multiply(feed_w, x) + b # y = wx+b cost = tf.reduce_mean(tf.square(hypothesis ..

Tensorflow Basic

1. type import tensorflow as tf # tensorflow import print(tf.__version__) # version check print(1, type(1)) print(1, type([1])) print(tf.constant(1), type(tf.constant(1))) # scalar, 0 D tensor print(tf.constant([1])) # vector, 1 D tensor print(tf.constant([[1]])) # matrix, 2 D tensor print(tf.rank(tf.constant([[1]]))) # 2차원 확인 ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ 1 1 tf.Tensor(1, shape=(), dtype=int..