Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import numpy as np
  2. from keras.models import Sequential
  3. from keras.layers import Deconv2D, Lambda
  4.  
  5. def cropped_shape(inshape):
  6. samples, ch, w, h = inshape
  7. return (samples, ch, w - 2, h - 2)
  8.  
  9. mdl = Sequential()
  10. mdl.add(Deconv2D(256, input_shape=(1, 7, 7), padding='valid', kernel_size=4, strides=2, data_format="channels_first"))
  11. mdl.add(Lambda(lambda x: x[:, :, 1:-1, 1:-1], output_shape=cropped_shape))
  12. mdl.summary()
  13. mdl.compile(loss='mse', optimizer='sgd')
  14. x = np.random.normal(size=(1,1,7,7))
  15. y = mdl.predict_on_batch(x)
  16. print y.shape
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement