E Calc node Resize : /Resize output shape fail W ----------------Warning(1)---------------- Traceback (most recent call last): File "acuitylib/onnx_ir/onnx_numpy_backend/shape_inference.py", line 52, in infer_shape File "/home/xr/acuity-toolkit-binary-5.14.1/bin/acuitylib/acuitylib/onnx_ir/onnx_numpy_backend/ops/resize.py", line 229, in Resize roi = None if inputs[1].size == 0 else inputs[1] AttributeError: 'str' object has no attribute 'size' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "convertonnx.py", line 52, in <module> File "convertonnx.py", line 45, in main File "acuitylib/vsi_nn.py", line 135, in load_onnx File "acuitylib/app/importer/import_onnx.py", line 116, in run File "acuitylib/converter/convert_onnx.py", line 62, in __init__ File "acuitylib/converter/convert_onnx.py", line 321, in _shape_inference File "acuitylib/onnx_ir/onnx_numpy_backend/shape_inference.py", line 54, in infer_shape File "acuitylib/acuitylog.py", line 251, in e ValueError: Calc node Resize : /Resize output shape fail [1149115] Failed to execute script convertonnx
时间: 2024-04-13 18:24:38 浏览: 13
这个错误是由于在执行计算图中的 Resize 操作时,输出形状推断失败导致的。错误信息中显示了一个 AttributeError,指示字符串对象没有一个名为 'size' 的属性。这可能是由于在 Resize 操作中的某个地方出现了错误。
为了解决这个问题,你可以尝试以下几个步骤:
1. 检查输入数据的格式和类型是否正确。确保输入数据与模型期望的形状和类型匹配。
2. 检查 Resize 操作的参数是否正确设置。确保输入数据和目标形状的尺寸是有效的,并且与模型期望的尺寸一致。
3. 如果你使用的是第三方库或框架,查看其文档或示例代码,以确保正确使用 Resize 操作。
4. 如果问题仍然存在,尝试更新相关库或框架的版本,可能存在某些已知的问题或bug。
5. 如果你无法解决问题,建议向Acuity Toolkit的官方支持渠道寻求帮助,他们可能能够更具体地指导你解决此问题。
请注意,由于我无法确定你所使用的具体环境和代码细节,以上建议仅供参考。对于更具体的问题解决方案,请参考相关文档或寻求相应的支持渠道。
相关问题
https://c.runoob.com/front-end/61/
这个链接是一个在线的 JavaScript 计算器,它的实现方式与上面提到的类似,不过它使用了更为完整和复杂的 JavaScript 代码。
具体来说,这个计算器的实现步骤如下:
1. HTML 部分
在 HTML 文件中,创建一个表单,其中包含一个输入框和一些按钮,如下所示:
```html
<form name="calculator">
<table>
<tr>
<td colspan="4">
<input type="text" name="result" id="result" readonly>
</td>
</tr>
<tr>
<td><input type="button" value="1" onclick="calculator.result.value += '1'"></td>
<td><input type="button" value="2" onclick="calculator.result.value += '2'"></td>
<td><input type="button" value="3" onclick="calculator.result.value += '3'"></td>
<td><input type="button" value="/" onclick="calculator.result.value += '/'"></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="calculator.result.value += '4'"></td>
<td><input type="button" value="5" onclick="calculator.result.value += '5'"></td>
<td><input type="button" value="6" onclick="calculator.result.value += '6'"></td>
<td><input type="button" value="*" onclick="calculator.result.value += '*'"></td>
</tr>
<tr>
<td><input type="button" value="7" onclick="calculator.result.value += '7'"></td>
<td><input type="button" value="8" onclick="calculator.result.value += '8'"></td>
<td><input type="button" value="9" onclick="calculator.result.value += '9'"></td>
<td><input type="button" value="-" onclick="calculator.result.value += '-'"></td>
</tr>
<tr>
<td><input type="button" value="C" onclick="calculator.result.value = ''"></td>
<td><input type="button" value="0" onclick="calculator.result.value += '0'"></td>
<td><input type="button" value="=" onclick="calculator.result.value = eval(calculator.result.value)"></td>
<td><input type="button" value="+" onclick="calculator.result.value += '+'"></td>
</tr>
</table>
</form>
```
在这个表单中,我们也是使用了一个只读的文本框用于显示计算结果,以及一些按钮用于输入数字和运算符。不同的是,这里的按钮并没有使用函数调用,而是直接在 onclick 属性中编写了 JavaScript 代码。
2. JavaScript 部分
在 JavaScript 文件中,我们需要编写更为复杂的代码来实现计算器的功能。
首先,我们需要定义一个 eval() 函数,用于计算表达式的值:
```javascript
function eval() {
try {
return eval(arguments[0]);
} catch (e) {
return 'Error';
}
}
```
在这个函数中,我们使用了 try-catch 语句来捕获可能的运行时错误,避免程序崩溃。
接着,我们需要编写一个 calc() 函数,用于将字符串表达式转换为可计算的表达式:
```javascript
function calc() {
calculator.result.value = eval(calculator.result.value);
}
```
在这个函数中,我们使用了 eval() 函数来计算表达式的值,并将计算结果赋值给文本框。
最后,我们需要编写一些函数来处理一些特殊情况,例如小数点、正负号、百分号等。这些函数的具体实现可以参考链接中给出的代码。
通过上述这些步骤,我们就可以实现一个完整的 JavaScript 计算器了。
利用公式π/4=1-1/3
根据公式π/4=1-1/3+1/5-1/7+1/9-...,可以利用循环计算π的值。以下是两种不同语言的实现方法:
Python实现:
```python
def calc_pi(n):
pi = 0
for i in range(n):
if i % 2 == 0:
pi += 1 / (2 * i + 1)
else:
pi -= 1 / (2 * i + 1)
return pi * 4
print(calc_pi(1000000)) # 输出:3.1415916535897743
```
Java实现:
```java
public class CalcPi {
public static double calcPi(int n) {
double pi = 0;
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
pi += 1.0 / (2 * i + 1);
} else {
pi -= 1.0 / (2 * i + 1);
}
}
return pi * 4;
}
public static void main(String[] args) {
System.out.println(calcPi(1000000)); // 输出:3.1415916535897743
}
}
```