from tensorflow.keras.models import Sequential
# CREATE NEW MODEL
model = Sequential()
base 층
from tensorflow.keras.layers import Dense
model.add(Dense(128, activation='relu'))
다차원 형태의 데이터를 1줄로 펴줌
from tensorflow.keras.layers import Flatten
model.add(Flatten(input_shape=(32, 32, 3)))
model.add(Flatten())
별 쓸모 없음 dense 안에 넣을 수 있음.
from keras.models import Sequential
from keras.layers import Dense, Activation
model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'))
model = Sequential([
Dense(32, input_shape=(784,)),
Activation('relu'),
Dense(10),
Activation('softmax'),
])
2차원 레이어로 평균 pooling
tf.keras.layers.GlobalAveragePooling2D(
data_format=None, keepdims=False, **kwargs
)
>>> input_shape = (2, 4, 5, 3)
>>> x = tf.random.normal(input_shape)
>>> y = tf.keras.layers.GlobalAveragePooling2D()(x)
>>> print(y.shape)
(2, 3)