Layers>Permute层

Permute(dims)置换输入的维度。

dims: 整数元组。

model = Sequential()
model.add(Permute((2, 1), input_shape=(10, 64)))
# now: model.output_shape == (None, 64, 10)
# note: `None` is the batch dimension

输入shape

任意,当使用激活层作为第一层时,要指定input_shape

输出shape

与输入相同,但是其维度按照指定的模式重新排列

帮我用pytorch改写:def make_generator_model(): model = tf.keras.Sequential() model.add(layers.Input(shape=(100, 12))) model.add(layers.Bidirectional(layers.LSTM(64, return_sequences=True))) model.add(layers.Conv1D(filters=128, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.Conv1D(filters=64, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.UpSampling1D(2)) model.add(layers.Conv1D(filters=32, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.Conv1D(filters=16, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.UpSampling1D(2)) model.add(layers.Conv1D(filters=1, kernel_size=16, strides=1, padding='same', activation='tanh')) model.add(layers.Permute((2, 1))) return model def make_discriminator_model(): model = tf.keras.Sequential() model.add(layers.Input(shape=(1, 400))) model.add(layers.Permute((2, 1))) model.add(layers.Conv1D(filters=32, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) # model.add(layers.Dropout(0.4)) model.add(layers.Conv1D(filters=64, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.MaxPool1D(pool_size=2)) model.add(layers.Conv1D(filters=128, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) # model.add(layers.Dropout(0.4)) model.add(layers.Conv1D(filters=256, kernel_size=16, strides=1, padding='same')) model.add(layers.LeakyReLU()) model.add(layers.MaxPool1D(pool_size=2)) model.add(layers.Flatten()) model.add(layers.Dense(1)) return model
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值