99and that the input preprocessing function 
1010is also different (same as Inception V3). 
1111
12- Also do note that this model is only available for the TensorFlow backend, 
13- due to its reliance on `SeparableConvolution` layers. 
14- 
1512# Reference 
1613
1714- [Xception: Deep Learning with Depthwise Separable Convolutions](https://arxiv.org/abs/1610.02357) 
3734from  ..layers  import  GlobalMaxPooling2D 
3835from  ..engine  import  get_source_inputs 
3936from  ..utils .data_utils  import  get_file 
37+ from  ..utils  import  layer_utils 
4038from  .. import  backend  as  K 
4139from  . import  imagenet_utils 
4240from  .imagenet_utils  import  decode_predictions 
@@ -53,10 +51,8 @@ def Xception(include_top=True, weights='imagenet',
5351             classes = 1000 ):
5452    """Instantiates the Xception architecture. 
5553
56-     Optionally loads weights pre-trained 
57-     on ImageNet. This model is available for TensorFlow only, 
58-     and can only be used with inputs following the TensorFlow 
59-     data format `(width, height, channels)`. 
54+     Optionally loads weights pre-trained on ImageNet. This model can 
55+     only be used with the data format `(width, height, channels)`. 
6056    You should set `image_data_format='channels_last'` in your Keras config 
6157    located at ~/.keras/keras.json. 
6258
@@ -110,9 +106,6 @@ def Xception(include_top=True, weights='imagenet',
110106        raise  ValueError ('If using `weights` as imagenet with `include_top`' 
111107                         ' as true, `classes` should be 1000' )
112108
113-     if  K .backend () !=  'tensorflow' :
114-         raise  RuntimeError ('The Xception model is only available with ' 
115-                            'the TensorFlow backend.' )
116109    if  K .image_data_format () !=  'channels_last' :
117110        warnings .warn ('The Xception model is only available for the ' 
118111                      'input data format "channels_last" ' 
@@ -261,6 +254,8 @@ def Xception(include_top=True, weights='imagenet',
261254                                    cache_subdir = 'models' ,
262255                                    file_hash = 'b0042744bf5b25fce3cb969f33bebb97' )
263256        model .load_weights (weights_path )
257+         if  K .backend () ==  'theano' :
258+             layer_utils .convert_all_kernels_in_model (model )
264259    elif  weights  is  not   None :
265260        model .load_weights (weights )
266261
0 commit comments