Package Precision

本文介绍了在数值计算中处理浮点数精度问题的方法,强调了直接比较浮点数的不可行性,并提供了正确的比较方式。此外,还讨论了在不同几何空间中选择合适精度标准的重要性。

Precision Class Reference

The Precision package offers a set of functions defining precision criteria 
for use in conventional situations when comparing two numbers. 
Generalities 
It is not advisable to use floating number equality. Instead, the difference 
between numbers must be compared with a given precision, i.e. : 
Standard_Real x1, x2 ; 
x1 = ... 
x2 = ... 
If ( x1 == x2 ) ... 
should not be used and must be written as indicated below: 
Standard_Real x1, x2 ; 
Standard_Real Precision = ... 
x1 = ... 
x2 = ... 
If ( Abs ( x1 - x2 ) < Precision ) ... 
Likewise, when ordering floating numbers, you must take the following into account : 
Standard_Real x1, x2 ; 
Standard_Real Precision = ... 
x1 = ... ! a large number 
x2 = ... ! another large number 
If ( x1 < x2 - Precision ) ... 
is incorrect when x1 and x2 are large numbers ; it is better to write : 
Standard_Real x1, x2 ; 
Standard_Real Precision = ... 
x1 = ... ! a large number 
x2 = ... ! another large number 
If ( x2 - x1 > Precision ) ... 
Precision in Cas.Cade 
Generally speaking, the precision criterion is not implicit in Cas.Cade. Low-level geometric algorithms accept 
precision criteria as arguments. As a rule, they should not refer directly to the precision criteria provided by the 
Precision package. 
On the other hand, high-level modeling algorithms have to provide the low-level geometric algorithms that they 
call, with a precision criteria. One way of doing this is to use the above precision criteria. 
Alternatively, the high-level algorithms can have their own system for precision management. For example, the 
Topology Data Structure stores precision criteria for each elementary shape (as a vertex, an edge or a face). When 
a new topological object is constructed, the precision criteria are taken from those provided by the Precision 
package, and stored in the related data structure. Later, a topological algorithm which analyses these objects will 
work with the values stored in the data structure. Also, if this algorithm is to build a new topological object, from 
these precision criteria, it will compute a new precision criterion for the new topological object, and write it into the 
data structure of the new topological object. 
The different precision criteria offered by the Precision package, cover the most common requirements of 
geometric algorithms, such as intersections, approximations, and so on. 
The choice of precision depends on the algorithm and on the geometric space. The geometric space may be : 

  • a "real" 2D or 3D space, where the lengths are measured in meters, millimeters, microns, inches, etc ..., or 
  • a "parametric" space, 1D on a curve or 2D on a surface, where lengths have no dimension. 
    The choice of precision criteria for real space depends on the choice of the product, as it is based on the accuracy 
    of the machine and the unit of measurement. 
    The choice of precision criteria for parametric space depends on both the accuracy of the machine and the 
    dimensions of the curve or the surface, since the parametric precision criterion and the real precision criterion are 
    linked : if the curve is defined by the equation P(t), the inequation : 
    Abs ( t2 - t1 ) < ParametricPrecision 
    means that the parameters t1 and t2 are considered to be equal, and the inequation : 
    Distance ( P(t2) , P(t1) ) < RealPrecision 
    means that the points P(t1) and P(t2) are considered to be coincident. It seems to be the same idea, and it 
    would be wonderful if these two inequations were equivalent. Note that this is rarely the case ! 
    What is provided in this package? 
    The Precision package provides : 
  • a set of real space precision criteria for the algorithms, in view of checking distances and angles, 
  • a set of parametric space precision criteria for the algorithms, in view of checking both : 
    • the equality of parameters in a parametric space, 
    • or the coincidence of points in the real space, by using parameter values, 
  • the notion of infinite value, composed of a value assumed to be infinite, and checking tests designed to verify 
    if any value could be considered as infinite. 
    All the provided functions are very simple. The returned values result from the adaptation of the applications 
    developed by the Open CASCADE company to Open CASCADE algorithms. The main interest of these functions 
    lies in that it incites engineers developing applications to ask questions on precision factors. Which one is to be 
    used in such or such case ? Tolerance criteria are context dependent. They must first choose : 
  • either to work in real space, 
  • or to work in parametric space, 
  • or to work in a combined real and parametric space. 
    They must next decide which precision factor will give the best answer to the current problem. Within an application 
    environment, it is crucial to master precision even though this process may take a great deal of time. 

#include <Precision.hxx>


介绍precision 有两种一种是参数空间(parameter space),一种是带单位的实数空间(real space )

注意:在一维情况下,需要注意两者的统一。

OCC 中内部的dimension 是millimeter

  • The SI System

The SI System is the standard international unit system. It is indicated by SI in the signature of the UnitsAPI functions

The Open CASCADE (former MDTV) System corresponds to the SI international standard bu the length unit and all its derivatives 

use the millimeter instead of meter

I guess the meter is to big and not convenient for the CAX users

### 如何在Kaggle上使用特定的训练包进行机器学习模型训练 #### 登录并创建新Notebook 要在Kaggle平台上使用特定的Python库或R包来进行机器学习模型训练,首先需要完成登录过程[^1]。之后可以在Kernels页面点击“New Notebook”,从而进入Jupyter风格的工作环境。 #### 安装额外软件包 对于那些不在默认环境中预先安装好的第三方库,可以通过运行`!pip install package_name`命令来临时安装所需的Python包;如果是R语言,则可使用`install.packages('package')`语句实现相同目的。需要注意的是,这些更改仅适用于当前会话期间,并不会影响其他用户的Kernel实例或者持久化到平台的基础镜像中。 ```python # Python example of installing a new library within the Kaggle kernel environment. !pip install some-python-package --quiet ``` #### 导入必要的模块 一旦确认所需工具已经可用,下一步就是导入它们以便后续操作: ```python import pandas as pd from sklearn.model_selection import train_test_split, KFold from sklearn.metrics import accuracy_score from keras.models import Sequential from keras.layers import Dense ``` 上述代码片段展示了如何加载Pandas用于数据处理、Scikit-Learn支持的数据分割功能以及构建简单的前馈神经网络所需要的Keras组件。 #### 数据准备与预处理 按照惯例,在实际建模之前应当先准备好干净整齐的数据集。这通常涉及到读取原始文件、清理异常值、填补缺失项等一系列步骤。此外,还应该考虑执行标准化/归一化转换以提高某些算法的表现效果。 #### 构建和配置模型架构 定义好输入层尺寸后可以根据具体应用场景灵活调整隐藏层数量及其单元数,同时指定激活函数类型等超参数设置。例如,当面对二分类任务时可以选择sigmoid作为最后一层输出节点处应用的非线性映射关系。 #### 训练流程控制 借助于内置回调机制(Callback),能够方便地监控整个迭代过程中各项指标的变化趋势,进而采取适当措施防止过早停止现象发生或是保存最佳权重副本供最终部署阶段调用。另外,由于题目提到想要增大batch size却受限于本地硬件条件不足的情况,此时正好可以充分利用云端资源的优势——即允许设定较大的批量大小而不用担心内存溢出风险。 #### 验证策略实施 考虑到泛化能力的重要性,建议采用交叉验证方法论[K折交叉验证](https://en.wikipedia.org/wiki/Cross-validation_(statistics))对候选方案进行全面检验。这种方式有助于更稳定可靠地估计未知样本上的预期误差范围,同时也便于识别潜在模式偏差问题的存在与否[^3]。 #### 性能评估标准确立 最后一步则是挑选合适的度量准则用来量化预测质量的好坏程度。针对不同的业务需求可能会有不同的侧重点,比如精确率(Precision)、召回率(Recall)或者是F1 Score等等。当然也可以综合多个方面给出更加全面的成绩报告单。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值