ceil 官方文档:https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/layers_cn/ceil_cn.html
floor 官方文档:https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/layers_cn/floor_cn.html
ceil 示例:
import paddle.fluid as fluid
import numpy as np
input_ceil = np.array([[-1.5, 6], [1, 15.6]])
with fluid.dygraph.guard():
x = fluid.dygraph.to_variable(input_ceil)
y = fluid.layers.ceil(x)
print(y.numpy())
结果:
[[-1. 6.]
[ 1. 16.]]
floor 示例:
import paddle.fluid as fluid
with fluid.dygraph.guard():
data1 = fluid.layers.fill_constant(shape=[3, 2], value=2.5, dtype='float32') # [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]]
data2 = fluid.layers.fill_constant(shape=[2, 3], value=-2.5, dtype='float64') # [[-2.5, -2.5, -2.5], [-2.5, -2.5, -2.5]]
result1 = fluid.layers.floor(data1) # [[2., 2.], [2., 2.], [2., 2.]]
result2 = fluid.layers.floor(data2) # [[-3., -3., -3.], [-3., -3., -3.]]
print(result1.numpy())
print(result2.numpy())
结果:
[[2. 2.] [2. 2.] [2. 2.]] [[-3. -3. -3.] [-3. -3. -3.]]