def check_composed_tensor_operations(first_function_name, first_function_args, second_function_name, second_function_args, input_shape):
 val = (np.random.random(input_shape) - 0.5)
 xth = KTH.variable(val)
 xtf = KTF.variable(val)
 yth = getattr(KTH, first_function_name)(xth, **first_function_args)
 ytf = getattr(KTF, first_function_name)(xtf, **first_function_args)
 zth = KTH.eval(getattr(KTH, second_function_name)(yth, **second_function_args))
 ztf = KTF.eval(getattr(KTF, second_function_name)(ytf, **second_function_args))
 assert (zth.shape == ztf.shape)
 assert_allclose(zth, ztf, atol=1e-05)

def check_composed_tensor_operations ( first_function_name , first_function_args , second_function_name , second_function_args , input_shape ) : val = ( np . random . random ( input_shape ) - 0.5 ) xth = KTH . variable ( val ) xtf = KTF . variable ( val ) yth = getattr ( KTH , first_function_name ) ( xth , ** first_function_args ) ytf = getattr ( KTF , first_function_name ) ( xtf , ** first_function_args ) zth = KTH . eval ( getattr ( KTH , second_function_name ) ( yth , ** second_function_args ) ) ztf = KTF . eval ( getattr ( KTF , second_function_name ) ( ytf , ** second_function_args ) ) assert ( zth . shape == ztf . shape ) assert_allclose ( zth , ztf , atol = 1e-05 )
creates a random tensor t0 with shape input_shape and compute t1 = first_function_name t2 = second_function_name with both theano and tensorflow backends and ensures the answers match .