Single input, Single output - pai-plznw4me/tensorflow_basic GitHub Wiki

1. Input

input_ = Input(shape=[784], name='input_')

Input shape argument Datatype 으로는 tuple, list 가 가능하다.

tuple case
x1 = Input(shape=(784,), name='input_')

2 . 여러 layer 연결 및 output 생성

   from tensorflow.keras.models import Model
   from tensorflow.keras.layers import Input, Dense
   import tensorflow as tf
   
   input_ = Input(shape=[784], name='input_')
   layer1 = Dense(units=256, activation='relu')(input_)
   layer2 = Dense(units=256, activation='relu')(layer1)
   output = Dense(units=10, activation='relu')(layer2)

3 . 모델 생성

   # model 생성 
   model = Model(input_, output)

4. 모델 사용

# model 실행
x = tf.zeros(shape=[1, 784])
print(model.predict(x))
__call__ 사용한 모델 실행
model(x)
⚠️ **GitHub.com Fallback** ⚠️