def random_zoom(x, zoom_range, row_axis=1, col_axis=2, channel_axis=0, fill_mode='nearest', cval=0.0):
 if (len(zoom_range) != 2):
  raise ValueError('zoom_range should be a tuple or list of two floats. Received arg: ', zoom_range)
 if ((zoom_range[0] == 1) and (zoom_range[1] == 1)):
  (zx, zy) = (1, 1)
 else:
  (zx, zy) = np.random.uniform(zoom_range[0], zoom_range[1], 2)
 zoom_matrix = np.array([[zx, 0, 0], [0, zy, 0], [0, 0, 1]])
 (h, w) = (x.shape[row_axis], x.shape[col_axis])
 transform_matrix = transform_matrix_offset_center(zoom_matrix, h, w)
 x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval)
 return x

def random_zoom ( x , zoom_range , row_axis = 1 , col_axis = 2 , channel_axis = 0 , fill_mode = 'nearest' , cval = 0.0 ) : if ( len ( zoom_range ) != 2 ) : raise ValueError ( 'zoom_range should be a tuple or list of two floats. Received arg: ' , zoom_range ) if ( ( zoom_range [ 0 ] == 1 ) and ( zoom_range [ 1 ] == 1 ) ) : ( zx , zy ) = ( 1 , 1 ) else : ( zx , zy ) = np . random . uniform ( zoom_range [ 0 ] , zoom_range [ 1 ] , 2 ) zoom_matrix = np . array ( [ [ zx , 0 , 0 ] , [ 0 , zy , 0 ] , [ 0 , 0 , 1 ] ] ) ( h , w ) = ( x . shape [ row_axis ] , x . shape [ col_axis ] ) transform_matrix = transform_matrix_offset_center ( zoom_matrix , h , w ) x = apply_transform ( x , transform_matrix , channel_axis , fill_mode , cval ) return x
performs a random spatial zoom of a numpy image tensor .