模型input使用問題
2019/12/26 上午 09:47
電腦視覺深度學習討論版
呂家緯
觀看數:20
回答數:1
收藏數:0
請問再寫卷積網路層時
有時看範例程式
有時input放在函式裡面 有時放在外面
如(1)與(2):
(1)x
=
Convolution2D
(
filters
=
32
,
kernel_size
=
(
6
,
6
),
strides
=
(
1
,
1
))
(
inputs
)
(2)x
=
Convolution2D
(
filters
=
32
,
kernel_size
=
(
6
,
6
),
strides
=
(
1
,
1
)
,
inputs_shape = inputs
)
請問差別在哪裡呢?
還有 下列定義input時兩者之間的差別在哪裡呢?
input = (13,13,1)與 input = Input(shape=(13,13,1))
非常感謝解答
回答列表
-
2019/12/26 上午 10:50楊哲寧贊同數:2不贊同數:0留言數:0
您好,這是兩種不同搭法:
第一種搭法是使用add方式堆疊NN層,在第一層時要先給input_shape,算是一個argument。
classifier=Sequential()
classifier.add(Convolution2D(32,3,3,input_shape=(28,28,1)))
第二種方式則是用x = layer()(previous layer)方式堆疊,此時input要先用Input API定義。
inputs = Input(shape=(784,))
x=Dense(288)(inputs)
model = Model(inputs=inputs, outputs=x)
input = (13,13,1)與input = Input(shape=(13,13,1))的差別在於Input是一個Keras的API,假如用第二種方式打包模型就要先使用