Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use np.finfo in numpy

Shulou Source: shulou.com Published: 2022-06-02 09:54:16 11月15日 Update

This article shows you how to use np.finfo in numpy. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Example: "" the np.finfo method eps is a small non-negative division whose denominator cannot be 0, or it will directly pop up to display an error. Use eps to replace the possible petty eps so that no error will be reported. "" Import numpy as npx = np.array ([1,2,3], dtype=float) eps = np.finfo (x.dtype). Eps # eps = 2.220446049250313e-16 type= print (eps, type (eps)) height = np.array ([0,2,3], dtype=float) height = np.maximum (height, eps) # once 0 appears in height Replace print (height) # [2.22044605e-16 2.00000000e+00 3.00000000e+00] dy = x / heightprint (dy) # [4.50359963e+15 1.00000000e+00 1.00000000e+00] with eps

The above is how to use np.finfo in numpy. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Content skills knowledge conciseness conciseness usage examples denominator that is articles methods more articles industries negative numbers information channels errors division channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information vpn Microsoft NVidia