Skip to content

Instantly share code, notes, and snippets.

"""Fix + workaround for bug involving Lambda."""
import numpy as np
import tensorflow as tf
from keras import backend as K
from keras.layers import Convolution2D, Lambda
from keras.models import Sequential, model_from_json, model_from_yaml
def resize_im(x, height_factor, width_factor, dim_ordering):
return K.resize_images(x, height_factor, width_factor, dim_ordering)
@allanzelener
allanzelener / lambda_bug.py
Created February 10, 2017 02:27
Small reproduction of bug involving serialization of Lambda layer in Keras.
"""Small reproduction of bug involving Lambda."""
import tensorflow as tf
from keras import backend as K
from keras.layers import Convolution2D, Lambda
from keras.models import Sequential, model_from_json, model_from_yaml
def space_to_depth_output_shape(input_shape):
return (input_shape[0], input_shape[1] // 2, input_shape[2] // 2,
4 * input_shape[3]) if input_shape[1] else (