摘要:``` #include #include #include int main() { struct timeval start, end; gettimeofday(&start, NULL); sleep(2); gettimeofday(&end, NULL); long seconds = end.tv_sec - start.tv_sec; long micros =...
阅读全文
摘要:有同学改bug的思路是:你们别管我怎么改,先看改的效果对不对。效果对,就这样改,效果不对,我再想别的办法。这样其实把自己关起来,盲目试错,效率太低。 合理的方法应该是和其他大佬们商量一个大家认为正确的思路,然后就坚决地按这个思路改,逢山开路遇河架桥。真是遇到困难解决不了,就把问题抛出来,大家再一起商
阅读全文
摘要:```
# coding: utf-8
import re
text = "aa[bb,aa#cWc中a国"
FILTER_PUNTS = re.compile("[^\u4E00-\u9FA5|^a-z|^A-Z]")
text = FILTER_PUNTS.sub(" ", text.strip())
print(text)
```
阅读全文
摘要:训练的代码,以cifar为例 c++推理代码 include include include include int main(int argc, const char argv[]) { if (argc != 2) { std::cerr \n"; return 1; } // Deserial
阅读全文
摘要:想跑通第1个参考资料上讲的例子,一定要注意gcc和gperftools的版本.因为LibTorch用了c++17的over aligned新特性. centos默认的gcc是4.8.5不支持这个新特性,直接用会一直报Attempt to free invalid pointer 0xxxxxx Ab
阅读全文
摘要:padding是输入数据最边缘补0的个数,默认是0,即不补0. stride是进行一次卷积后,特征图滑动几格,默认是1,即滑动一格.
阅读全文
摘要:最后打印的fp的值和第一个线程中初始化的不一样。第一个线程中结构体是个局部变量,函数返回,内存被回收。所以在主线程中就不能访问fp的值。如果想在主线程中获取子线程的值,就要用malloc初始化。
阅读全文
摘要:``` include include include include void thread_func(void arg){ int a = (int )arg; printf("tid=%lu,a=%d\n", pthread_self(), a); return ((void )0); } i
阅读全文
摘要:```
package main import "fmt" func fn_test_panic() (a int) { a = 2 panic("This is panic") return a
} func fn1() (a int) { a = 3 defer func(){ if p := recover(); p != nil { fmt.Println("re...
阅读全文