Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from keras.models import Sequential
- from keras.layers import Deconv2D, Lambda
- def cropped_shape(inshape):
- samples, ch, w, h = inshape
- return (samples, ch, w - 2, h - 2)
- mdl = Sequential()
- mdl.add(Deconv2D(256, input_shape=(1, 7, 7), padding='valid', kernel_size=4, strides=2, data_format="channels_first"))
- mdl.add(Lambda(lambda x: x[:, :, 1:-1, 1:-1], output_shape=cropped_shape))
- mdl.summary()
- mdl.compile(loss='mse', optimizer='sgd')
- x = np.random.normal(size=(1,1,7,7))
- y = mdl.predict_on_batch(x)
- print y.shape
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement