我有这样一个数组a:
a = [[40, 10], [50, 11]]
Run Code Online (Sandbox Code Playgroud)
我需要分别计算每个维度的平均值,结果应为:
[45, 10.5]
Run Code Online (Sandbox Code Playgroud)
45是平均a[*][0]和10.5平均a[*][1].
在不使用循环的情况下解决此问题的最优雅方法是什么?
我在具有8 GB RAM的macOS上具有4个内核(8线程超线程)的Intel i7并行生成大约400,000,000(4亿)个随机数.
但是,我也在DigitalOcean服务器上生成400,000,000个随机数,Debian上有20个内核,64 GB RAM.
这是代码:
import multiprocessing
import random
rangemin = 1
rangemax = 9
def randomGenPar_backend(backinput):
return random.randint(rangemin, rangemax)
def randomGenPar(num):
pool = multiprocessing.Pool()
return pool.map(randomGenPar_backend, range(0, num))
randNum = 400000000
random.seed(999)
randomGenPar(randNum)
Run Code Online (Sandbox Code Playgroud)
这些是基准测试的结果:
5,000,000 Random Numbers:
1 Core: 5.984
8 Core: 1.982
50,000,000 Random Numbers:
1 Core: 57.28
8 Core: 19.799
20 Core: 18.257
Times Benefit (20 core vs. 8 core) = 1.08
100,000,000 Random Numbers:
1 Core: 115
8 Core: 40.434
20 Core: 31.652 …Run Code Online (Sandbox Code Playgroud) python performance timing multiprocessing python-multiprocessing
我一直在尝试将IBM Watson文档转换服务与演示PDF一起使用,但它并没有将文档转换成一点点.所有它正在做的,是创建一个答案单元,这真的很长:
"text": "Watson is an artificially intelligent computer system capable of answering questions posed in natural language,[2] developed in IBM's DeepQA project by a research team led by principal investigator David Ferrucci. Watson was named after IBM's first CEO and industrialist Thomas J. Watson.[3][4] The computer system was specifically developed to answer questions on the quiz show Jeopardy![5] In 2011, Watson competed on Jeopardy! against former winners Brad Rutter and Ken Jennings.[3][6] Watson received the first place prize of …Run Code Online (Sandbox Code Playgroud) 在Watson图像识别(IR)演示中,您可以为应用程序提供图像,并对其进行分类,并告诉您它在图像中的含义.它是如何实现这一目标的?
至于我从文档中可以看出,你只能给它正面和负面的图像,它只能说'是',这是比萨,或'否',这不是比萨饼.它无法指定是披萨还是意大利面.
有没有办法实现这个目标?
machine-learning image-recognition ibm-watson visual-recognition