我想设计一个彩票调度器,我需要一个非常好的(伪)随机数发生器,类似于LCG,但我想知道是否还有其他更好的选择?我特意寻找用C语言编写的随机生成器.
LCG代码:
unsigned long lcg_rand(unsigned long a)
{
return (a * 279470273UL) % 4294967291UL;
}
Run Code Online (Sandbox Code Playgroud)
另外我想知道是否srand()可以用于此目的或不是非常准确?
我怎样才能解决这个问题?
(cv) jalal@klein:~/computer_vision/py-faster-rcnn/lib$ make
python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 58, in <module>
CUDA = locate_cuda()
File "setup.py", line 55, in locate_cuda
raise EnvironmentError('The CUDA %s path could not be located in %s' % (k, v))
OSError: The CUDA lib64 path could not be located in /usr/lib64
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
Run Code Online (Sandbox Code Playgroud)
我在Jupyter中遇到了用于上传文件的代码段,但是我不知道如何在执行代码的机器上保存该文件,或者如何显示上传文件的前5行。基本上,我正在寻找上传文件后访问该文件的正确命令:
import io
from IPython.display import display
import fileupload
def _upload():
_upload_widget = fileupload.FileUploadWidget()
def _cb(change):
decoded = io.StringIO(change['owner'].data.decode('utf-8'))
filename = change['owner'].filename
print('Uploaded `{}` ({:.2f} kB)'.format(
filename, len(decoded.read()) / 2 **10))
_upload_widget.observe(_cb, names='data')
display(_upload_widget)
_upload()
Run Code Online (Sandbox Code Playgroud) 我想编写一个简单的“C”程序来查找操作系统启动后的系统调用次数。我正在跟踪其他系统调用,例如 fork() 或 getpid() 并基本上复制它们的大部分内容。我不确定应该在哪里/何时增加计数器?有什么例子吗?
\n\n在 kernel/syscall.c 中定义计数器并相应地增加它是一个好主意吗?
\n\nvoid\nsyscall(void)\n{\n int num;\n counter++; //mona\n num = proc->tf->eax;\n if(num > 0 && num < NELEM(syscalls) && syscalls[num] != NULL) {\n proc->tf->eax = syscalls[num]();\n } else {\n cprintf("%d %s: unknown sys call %d\\n",\n proc->pid, proc->name, num);\n proc->tf->eax = -1;\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n另外,这是我迄今为止在 kernel/sysproc.c 中用于简单系统调用的代码:
\n\nsys_getsyscallinfo(void)\n{\n\n return counter; //mona\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但是我收到这个错误:
\n\nkernel/sysproc.c: In function \xe2\x80\x98sys_getsyscallinfo\xe2\x80\x99:\nkernel/sysproc.c:48: error: \xe2\x80\x98counter\xe2\x80\x99 undeclared (first use in this function)\nkernel/sysproc.c:48: error: (Each undeclared identifier is reported only …Run Code Online (Sandbox Code Playgroud) 我有以下内容 .git/config
1 [core]
2 repositoryformatversion = 0
3 filemode = true
4 bare = false
5 logallrefupdates = true
6 [remote "origin"]
7 url = git@github.com:monajalal/instagram-scraper.git
8 fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
当我尝试将更改推送到主服务器时,出现以下错误:
$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我都尝试过这两个,但仍然会出错:
2150 git remote set-url origin https://github.com/monajalal/instagram-scraper.git
2154 git remote set-url origin git@github.com:monajalal/instagram-scraper.git
mona@pascal:~/computer_vision/instagram/instagram$ git log
commit e69644389a5c7be65ae6eae14d74065e221600cb
Author: …Run Code Online (Sandbox Code Playgroud) 我按照本教程安装了适用于Windows 10的Tensorflow。但是,出现此错误。原因和解决方法是什么?
C:\Users\mona6>conda create -n tensorflow-gpu python=3.6
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment C:\Users\mona6\AppData\Local\conda\conda\envs\tensorflow-gpu:
The following NEW packages will be INSTALLED:
pip: 9.0.1-py36_1
python: 3.6.1-0
setuptools: 27.2.0-py36_1
vs2015_runtime: 14.0.25123-0
wheel: 0.29.0-py36_0
Proceed ([y]/n)? y
python-3.6.1-0 100% |###############################| Time: 0:00:01 17.89 MB/s
#
# To activate this environment, use:
# > activate tensorflow-gpu
#
# To deactivate this environment, use:
# > deactivate tensorflow-gpu
#
# * for power-users using bash, …Run Code Online (Sandbox Code Playgroud) 我该怎么解决这个问题?
Monas-MacBook-Pro:02_02 mona$ python
Python 3.6.1 |Anaconda custom (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/mona/anaconda/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libopenblasp-r0.2.19.dylib
Referenced from: /Users/mona/anaconda/lib/libopencv_hdf.3.2.0.dylib
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
安装opencv使用:
conda install -c conda-forge opencv=3.2.0
Run Code Online (Sandbox Code Playgroud)
甚至尝试过:
$ conda install -c anaconda openblas=0.2.19
Fetching package metadata ...........
Solving package specifications: …Run Code Online (Sandbox Code Playgroud) 我有:
$ python
Python 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
>>> quit()
$ nvidia-smi
Wed Oct 14 21:28:50 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. …Run Code Online (Sandbox Code Playgroud) 当尝试将旧 PyTorch 编写的代码转换为 1.9 时,我收到此错误:
(fashcomp) [jalal@goku fashion-compatibility]$ python main.py --name test_baseline --learned --l2_embed --datadir ../../../data/fashion/
/scratch3/venv/fashcomp/lib/python3.8/site-packages/torchvision/transforms/transforms.py:310: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
warnings.warn("The use of the transforms.Scale transform is deprecated, " +
+ Number of params: 3191808
<class 'torch.utils.data.dataloader.DataLoader'>
/scratch3/venv/fashcomp/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally …Run Code Online (Sandbox Code Playgroud) 我有以下代码,用于使用 WandB API 记录每个时期的训练和验证损失。但我不确定为什么我没有在同一时期得到 val 损失和训练损失。知道如何解决这个问题吗?
wandb.log({"train loss": train_epoch_loss,
"val loss": val_epoch_loss,
"epoch": epoch})
wandb.log({"train acc": train_epoch_acc,
"val acc": val_epoch_acc,
"epoch": epoch})
wandb.log({"best val acc": best_acc, "epoch": epoch})
Run Code Online (Sandbox Code Playgroud)