草庐IT

float_exception

全部标签

python - 不能在 64 位架构的 Python 中使用 128 位 float

我检查了我的python终端中指针的大小(在EnthoughtCanopyIDE中)通过importctypesprint(ctypes.sizeof(ctypes.c_voidp)*8)我有一个64位架构,使用numpy.float64就好了。但是我不能使用np.float128吗?np.array([1,1,1],dtype=np.float128)或np.float128(1)结果:AttributeError:'module'objecthasnoattribute'float128'我正在运行以下版本:sys.version_info(major=2,minor=7,micr

python - 关于 pandas.read_csv 的 float_precision 参数

documentation对于这篇文章标题中的论点,他说:float_precision:string,defaultNoneSpecifieswhichconvertertheCengineshoulduseforfloating-pointvalues.TheoptionsareNonefortheordinaryconverter,highforthehigh-precisionconverter,andround_tripfortheround-tripconverter.我想更多地了解所提到的三种算法,最好不要深入研究源代码1。问:这些算法是否有名称,我可以通过谷歌搜索来准确

python - websocket._exceptions.WebSocketProxyException : failed CONNECT via proxy status: 503

提供的答案需要更多关于使用qlik服务器进行身份验证的详细信息我正在尝试通过WebSockets使用证书连接到qlik。错误:websocket._exceptions.WebSocketProxyException:failedCONNECTviaproxystatus:503代码:fromwebsocketimportcreate_connectionimportsslsenseHost="dummy.xyz.com"privateKeyPath="C:\\ProgramData\\Qlik\\Sense\\Repository\\ExportedCertificates\\"##

python - "Exception ignored in"是什么类型的消息?

代码如下:defg():try:yield1yield2yield3exceptGeneratorExit:yield4gen=g()print(gen.__next__())如果你运行它你会看到:1Exceptionignoredin:RuntimeError:generatorignoredGeneratorExit我明白发生了什么,但我找不到这个警告是什么类型的消息。看起来它不是logging警告(我无法删除它设置日志记录级别)。它也不是warnings警告(它看起来不像我们调用warnings.warn时得到的)。我认为它可以与异常相关联,但我无法用sys.excepthook

Python Numpy : np. int32 "slower"比 np.float64

我想了解python的一个奇怪行为。让我们考虑一个矩阵M,其形状为6000x2000。该矩阵填充有符号整数。我想计算np.transpose(M)*M。两种选择:当我“自然地”执行此操作时(即没有指定任何类型),numpy选择类型np.int32并且该操作大约需要150秒。当我强制类型为np.float64(使用dtype=...)时,相同的操作大约需要2秒。我们如何解释这种行为?我天真地认为int乘法比float乘法便宜。非常感谢您的帮助。 最佳答案 不,整数乘法并不便宜。但稍后会详细介绍。很可能(我有99%的把握)numpy调用

python - 如何修复 'except ValueError' 处的无效语法错误?

我正在尝试编写一个简单的异常处理。然而,我似乎做错了什么。defaverage():TOTAL_VALUE=0FILE=open("Numbers.txt",'r')forlineinFILE:AMOUNT=float(line)TOTAL_VALUE+=AMOUNTNUMBERS_AVERAGE=TOTAL_VALUE/AMOUNTprint("theaverageofthenumbersin'Numbers.txt'is:",format(NUMBERS_AVERAGE,'.2f'))FILE.close()exceptValueError,IOErroraserr:print(e

python - 引发 Exception 类和 Exception 实例之间有区别吗?

在Python中,我可以通过两种方式引发异常raiseValueErrorraiseValueError()除了可以在后一种情况下提供异常消息之外,这两种样式之间有什么根本区别吗?我应该选择其中之一吗? 最佳答案 来自thedoc两者都有效(没有意外行为):Thesoleargumenttoraiseindicatestheexceptiontoberaised.Thismustbeeitheranexceptioninstanceoranexceptionclass(aclassthatderivesfromException).

python - float 必须是字符串还是数字?

我有一个非常简单的程序。代码:money=open("money.txt","r")moneyx=float(money)print(moneyx)文本文件money.txt仅包含以下内容:0.00我收到的错误信息是:TypeError:float()argumentmustbeastringoranumber这很可能是一个简单的错误。有什么建议吗?我正在使用Python3.3.3。 最佳答案 money是fileobject,不是文件的内容。要获取内容,您必须读取文件。如果整个文件只包含一个数字,那么read()就是您所需要的。m

python - TensorFlow 类型错误 : Value passed to parameter input has DataType uint8 not in list of allowed values: float16, float32

过去3天,我正在尝试让一个简单的CNN进行训练。首先,我设置了一个输入管道/队列配置,用于从目录树读取图像并准备批处理。我在这个link得到了代码.所以,我现在有train_image_batch和train_label_batch,我需要将它们提供给我的CNN。train_image_batch,train_label_batch=tf.train.batch([train_image,train_label],batch_size=BATCH_SIZE#,num_threads=1)我不知道怎么做。我正在使用此link中给出的CNN代码.#InputLayerinput_layer

Python float - str - 浮点怪异

>>>float(str(0.65000000000000002))0.65000000000000002>>>float(str(0.47000000000000003))0.46999999999999997???这是怎么回事?如何将0.47000000000000003转换为字符串并将结果值转换回float?我在Windows上使用Python2.5.4。 最佳答案 str(0.47000000000000003)给出'0.47'和float('0.47')可以是0.46999999999999997。这是由于float的表示