def convert_all_kernels_in_model(model):
 conv_classes = {'Convolution1D', 'Convolution2D', 'Convolution3D', 'AtrousConvolution2D', 'Deconvolution2D'}
 to_assign = []
 for layer in model.layers:
  if (layer.__class__.__name__ in conv_classes):
   original_w = K.get_value(layer.W)
   converted_w = convert_kernel(original_w)
   to_assign.append((layer.W, converted_w))
 K.batch_set_value(to_assign)

def convert_all_kernels_in_model ( model ) : conv_classes = { 'Convolution1D' , 'Convolution2D' , 'Convolution3D' , 'AtrousConvolution2D' , 'Deconvolution2D' } to_assign = [ ] for layer in model . layers : if ( layer . __class__ . __name__ in conv_classes ) : original_w = K . get_value ( layer . W ) converted_w = convert_kernel ( original_w ) to_assign . append ( ( layer . W , converted_w ) ) K . batch_set_value ( to_assign )
converts all convolution kernels in a model from theano to tensorflow .