我from object_detection.utils import label_map_util在 jupyter notebook 中执行时遇到了它。其实就是tensorflow对象检测教程notebook(自带tensorflow对象检测api)完整的错误日志:
AttributeError Traceback (most recent call last)
<ipython-input-7-7035655b948a> in <module>
1 from object_detection.utils import ops as utils_ops
----> 2 from object_detection.utils import label_map_util
3 from object_detection.utils import visualization_utils as vis_util
~\AppData\Roaming\Python\Python37\site-packages\object_detection\utils\label_map_util.py in <module>
25 import tensorflow as tf
26 from google.protobuf import text_format
---> 27 from object_detection.protos import string_int_label_map_pb2
28
29
~\AppData\Roaming\Python\Python37\site-packages\object_detection\protos\string_int_label_map_pb2.py in <module>
19 syntax='proto2',
20 serialized_options=None,
---> 21 create_key=_descriptor._internal_create_key,
22 serialized_pb=b'\n2object_detection/protos/string_int_label_map.proto\x12\x17object_detection.protos\"\xc0\x01\n\x15StringIntLabelMapItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\x05\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12M\n\tkeypoints\x18\x04 \x03(\x0b\x32:.object_detection.protos.StringIntLabelMapItem.KeypointMap\x1a(\n\x0bKeypointMap\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05label\x18\x02 \x01(\t\"Q\n\x11StringIntLabelMap\x12<\n\x04item\x18\x01 \x03(\x0b\x32..object_detection.protos.StringIntLabelMapItem'
23 ) …Run Code Online (Sandbox Code Playgroud) python protocol-buffers proto tensorflow object-detection-api
我认为直接创建起来会更快,但是实际上,添加循环只需要一半的时间。发生了什么,放慢了这么多?
这是测试代码
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class Test_newArray {
private static int num = 10000;
private static int length = 10;
@Benchmark
public static int[][] newArray() {
return new int[num][length];
}
@Benchmark
public static int[][] newArray2() {
int[][] temps = new int[num][];
for (int i = 0; i < temps.length; i++) {
temps[i] = new int[length];
}
return temps;
}
}
Run Code Online (Sandbox Code Playgroud)
测试结果如下。
Benchmark Mode Cnt Score Error Units
Test_newArray.newArray avgt 25 289.254 ± 4.982 us/op
Test_newArray.newArray2 avgt 25 114.364 ± 1.446 …Run Code Online (Sandbox Code Playgroud) 如果取一个数字,取其平方根,删除小数,然后将其提高到二次幂,结果应始终小于或等于原始数.
这似乎在python中都适用,直到你99999999999999975425出于某种原因尝试它.
import math
def check(n):
assert math.pow(math.floor(math.sqrt(n)), 2) <= n
check(99999999999999975424) # No exception.
check(99999999999999975425) # Throws AssertionError.
Run Code Online (Sandbox Code Playgroud)
它看起来像math.pow(math.floor(math.sqrt(99999999999999975425)), 2)回报1e+20.
我认为这与我们在python中存储值的方式有关...与浮点运算相关的东西,但我不能具体说明这会如何影响这种情况.
1:snprintf( buf, sizeof(buf),
2: "%s exe=%s hostname=%s addr=%s terminal=%s res=%s",
3: message, exename,
4: hostname ? hostname : "?",
5: addrbuf,
6: tty ? tty : "?",
7: success
);
Run Code Online (Sandbox Code Playgroud)
在上面的第6行代码中,“?”是什么?表示(不是三元运算符)
什么意思tty : tty : "?"
#include<stdio.h>
void TOH(int,char,char,char);
int n;
void main()
{
printf("How many plates?");
scanf("%d",&n);
TOH(n,'A','B','C');
}
if (n==1)
printf("A -> B \n");
if (n==2) {
printf("A->C \n");
printf("A->B \n");
printf("C->B \n");
}
void TOH(int n,char x,char y,char z)
{
if(n>2)
{
TOH(n-1,x,z,y);
printf("\n%c -> %c",x,y);
TOH(n-1,z,y,x);
}
}
Run Code Online (Sandbox Code Playgroud)
我有输出错误:
turnuri.c:12:1: error: expected identifier or '('
if (n==1)
^
turnuri.c:15:1: error: expected identifier or '('
if (n==2) {
^
1 warning and 2 errors generated.
Run Code Online (Sandbox Code Playgroud)
为什么?谢谢
当我给它 1011 和 100 时,我收到这条消息: “进程返回 -1073741676 (0xC0000094) 执行时间:4.425 秒” 我不知道为什么如果我给它 99 和 100 它可以工作并且显示 0但是如果我给它 100,它就会开始给出上面的消息,它应该告诉我 n 中有多少个数字除以 k。
#include<iostream>
using namespace std;
void cate(int n,int k,int &x){
int u=n%10;
while(n){
if(k%u==0) x++;
n/=10;u=n%10;
}
}
int n,k,x;
int main()
{
cin>>n>>k;
cate(n,k,x);
cout<<x;
}
Run Code Online (Sandbox Code Playgroud)