def random_shear(x, intensity, row_axis=1, col_axis=2, channel_axis=0, fill_mode='nearest', cval=0.0):
 shear = np.random.uniform((- intensity), intensity)
 shear_matrix = np.array([[1, (- np.sin(shear)), 0], [0, np.cos(shear), 0], [0, 0, 1]])
 (h, w) = (x.shape[row_axis], x.shape[col_axis])
 transform_matrix = transform_matrix_offset_center(shear_matrix, h, w)
 x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval)
 return x

def random_shear ( x , intensity , row_axis = 1 , col_axis = 2 , channel_axis = 0 , fill_mode = 'nearest' , cval = 0.0 ) : shear = np . random . uniform ( ( - intensity ) , intensity ) shear_matrix = np . array ( [ [ 1 , ( - np . sin ( shear ) ) , 0 ] , [ 0 , np . cos ( shear ) , 0 ] , [ 0 , 0 , 1 ] ] ) ( h , w ) = ( x . shape [ row_axis ] , x . shape [ col_axis ] ) transform_matrix = transform_matrix_offset_center ( shear_matrix , h , w ) x = apply_transform ( x , transform_matrix , channel_axis , fill_mode , cval ) return x
performs a random spatial shear of a numpy image tensor .