def test_Ceil(tmpdir): data = np.asarray([0.2, 1.3, 4., 5.5, 0.0], np.float32) model = C.ceil(data) verify_no_input(model, tmpdir, 'ceil_0') x = C.input_variable(data.shape) model = C.ceil(x) verify_one_input(model, data, tmpdir, 'ceil_1')
def test_Ceil(tmpdir, dtype): with C.default_options(dtype=dtype): data = np.asarray([0.2, 1.3, 4., 5.5, 0.0], dtype) model = C.ceil(data) verify_no_input(model, tmpdir, 'ceil_0') x = C.input_variable(data.shape) model = C.ceil(x) verify_one_input(model, data, tmpdir, 'ceil_1')
def test_Ceil(tmpdir, dtype): with C.default_options(dtype = dtype): data = np.asarray([0.2, 1.3, 4., 5.5, 0.0], dtype) model = C.ceil(data) verify_no_input(model, tmpdir, 'ceil_0') x = C.input_variable(data.shape) model = C.ceil(x) verify_one_input(model, data, tmpdir, 'ceil_1')
def test_save_no_junk(tmpdir): """ Test for an issue with save() not having O_TRUNC mode resulting in possible junk at the end of file if it already exists """ try: import onnx except ImportError: pytest.skip('ONNX is not installed.') filename = os.path.join(str(tmpdir), R'no_junk.onnx') filename_new = os.path.join(str(tmpdir), R'no_junk_new.onnx') # Save a large model. g = C.ceil([1, 2, 3, 4, 5, 6, 7, 8] * 100) g.save(filename, format=C.ModelFormat.ONNX) # Save a smaller model using the same file name and a new file name. g = C.ceil([1, 2, 3, 4, 5, 6, 7] * 100) g.save(filename, format=C.ModelFormat.ONNX) g.save(filename_new, format=C.ModelFormat.ONNX) # Check the files can be loaded as standard ONNX files, # and both result in the same model. assert onnx.load(filename) == onnx.load(filename_new)
def ceil(arg, name=''): ''' The output of this operation is the element wise value rounded to the smallest integer greater than or equal to the input. Example: >>> C.eval(C.ceil([0.2, 1.3, 4., 5.5, 0.0])) [array([[ 1., 2., 4., 6., 0.]])] >>> C.eval(C.ceil([[0.6, 3.3], [1.9, 5.6]])) [array([[[ 1., 4.], [ 2., 6.]]])] Args: arg: input tensor name (str): the name of the node in the network (optional) Returns: :class:`cntk.Function` ''' from cntk import ceil left = sanitize_input(left, get_data_type(right)) right = sanitize_input(right, get_data_type(left)) return ceil(arg, name).output()