小编ilk*_*chu的帖子

如何解决“AttributeError:模块'google.protobuf.descriptor'没有属性'_internal_create_key”?

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

75
推荐指数
3
解决办法
6万
查看次数

为什么分配单个2D数组要比分配总大小和形状相同的多个1D数组的循环花费更长的时间?

我认为直接创建起来会更快,但是实际上,添加循环只需要一半的时间。发生了什么,放慢了这么多?

这是测试代码

@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)

java performance

72
推荐指数
2
解决办法
5014
查看次数

math.sqrt()和math.pow()中的不准确性来自大数字?

如果取一个数字,取其平方根,删除小数,然后将其提高到二次幂,结果应始终小于或等于原始数.

这似乎在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中存储值的方式有关...与浮点运算相关的东西,但我不能具体说明这会如何影响这种情况.

python sqrt pow

11
推荐指数
2
解决办法
1076
查看次数

TOTP Base32 与 Base64

我发现每个 TOTP 实现(甚至 RedHat 的 FreeOTP)都使用 Base32 编码/解码来生成秘密。为什么不使用 Base64,因为 Base32 使用了大约 20% 以上的空间,它的主要优点是,它更易于人类阅读?无论如何,它不会向用户显示。

虽然实现中的每条评论都表示其实现遵循RFC6238 / RFC4226,但我在 RFC 文档中找不到关于 Base32 的任何内容。

由于传输数据的安全性,将其转换为 Base32 或 Base64 显然是有意义的,但为什么不直接使用 Base64 呢?

java base64 one-time-password base32

9
推荐指数
1
解决办法
3130
查看次数

C:“”是什么?意思?

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 : "?"

c linux

-1
推荐指数
1
解决办法
105
查看次数

C 中的问题在 if 条件上带有括号

    #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)

为什么?谢谢

c output

-1
推荐指数
1
解决办法
73
查看次数

void 函数不能整除 99 以上的整数

当我给它 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)

c++

-1
推荐指数
1
解决办法
75
查看次数