小编fat*_*gon的帖子

python乌龟画布滚动

我正在使用python龟库绘制一个大图.无论何时绘制,显示的区域都是中心(即滚动条位于中间位置).我想滚动到左上角区域.有没有办法做到这一点?

python python-3.x

3
推荐指数
1
解决办法
879
查看次数

Julia 中带有数组广播的除法运算符

我能够将一个常量乘以一个数组,但无法对除法运算符执行相同的操作。预期的?

julia> 2 * [1,2,3]
3-element Array{Int64,1}:
 2
 4
 6

julia> 2 / [1,2,3]
ERROR: MethodError: no method matching /(::Int64, ::Array{Int64,1})
Closest candidates are:
  /(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:38
  /(::Union{Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, ::BigInt) at gmp.jl:381
  /(::T<:Integer, ::T<:Integer) where T<:Integer at int.jl:36
  ...
Run Code Online (Sandbox Code Playgroud)

julia

3
推荐指数
1
解决办法
5042
查看次数

TPU比GPU慢?

我刚刚尝试在Google Colab中使用TPU,我想看看TPU比GPU快多少。我惊讶地得到了相反的结果。

以下是NN。

  random_image = tf.random_normal((100, 100, 100, 3))
  result = tf.layers.conv2d(random_image, 32, 7)
  result = tf.reduce_sum(result)
Run Code Online (Sandbox Code Playgroud)

性能结果:

CPU: 8s
GPU: 0.18s
TPU: 0.50s
Run Code Online (Sandbox Code Playgroud)

我不知道为什么。...TPU的完整代码如下:

def calc():
  random_image = tf.random_normal((100, 100, 100, 3))
  result = tf.layers.conv2d(random_image, 32, 7)
  result = tf.reduce_sum(result)
  return result

tpu_ops = tf.contrib.tpu.batch_parallel(calc, [], num_shards=8)

session = tf.Session(tpu_address)
try:
  print('Initializing global variables...')
  session.run(tf.global_variables_initializer())
  print('Warming up...')
  session.run(tf.contrib.tpu.initialize_system())
  print('Profiling')
  start = time.time()
  session.run(tpu_ops)
  end = time.time()
  elapsed = end - start
  print(elapsed)
finally:
  session.run(tf.contrib.tpu.shutdown_system())
  session.close()
Run Code Online (Sandbox Code Playgroud)

gpu machine-learning tensorflow google-colaboratory google-cloud-tpu

3
推荐指数
1
解决办法
2854
查看次数

带有Angular 2问题的Kendo UI

试图关注http://www.telerik.com/kendo-angular-ui/getting-started/

从浏览器控制台得到此错误...服务器端没有错误...

<button kendoButton (click)="onButtonClick()" [ERROR ->][primary]=true >My Kendo UI Button</button>
"): AppComponent@9:46 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors:
Can't bind to 'primary' since it isn't a known property of 'button'. ("
<app-date>test</app-date>

<button kendoButton (click)="onButtonClick()" [ERROR ->][primary]=true >My Kendo UI Button</button>
"): AppComponent@9:46
    at TemplateParser.parse (http://localhost:4200/main.bundle.js:15261:19)
    at RuntimeCompiler._compileTemplate (http://localhost:4200/main.bundle.js:33578:51)
    at http://localhost:4200/main.bundle.js:33501:83
    at Set.forEach (native)
    at compile (http://localhost:4200/main.bundle.js:33501:47)
    at ZoneDelegate.invoke (http://localhost:4200/main.bundle.js:64762:28)
    at Zone.run (http://localhost:4200/main.bundle.js:64655:43)
    at http://localhost:4200/main.bundle.js:65021:57
    at ZoneDelegate.invokeTask (http://localhost:4200/main.bundle.js:64795:37) …
Run Code Online (Sandbox Code Playgroud)

kendo-ui-angular2 angular

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

由于地址已在使用,dovecot 无法启动

我升级了 Linux 内核,但 dovecot 无法启动,并出现以下错误消息:

Error: service(managesieve-login): listen(*, 4190) failed: Address already in use
Error: service(pop3-login): listen(*, 110) failed: Address already in use
Error: service(pop3-login): listen(*, 995) failed: Address already in use
Error: service(imap-login): listen(*, 143) failed: Address already in use
Error: service(imap-login): listen(*, 993) failed: Address already in use
Fatal: Failed to start listeners
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我找不到任何与这些端口号绑定的进程。以下所有命令均不返回任何内容。

# netstat -tulpn | grep 110
# ss -tulpn |grep 110
# fuser 110/tcp
# lsof -i :110
Run Code Online (Sandbox Code Playgroud)

我也尝试将设置更改listen为我的特定 IP 地址,但仍然失败。

知道我该如何解决这个问题吗?这是我的版本信息: …

linux dovecot

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

如何在 pandas 中对多列执行半连接?

假设我有这两个数据框:

>>> df1 = pd.DataFrame({'grp':[1,1,2], 'x':[6,4,2], 'y':[7,8,9]})
>>> df1
   grp  x  y
0    1  6  7
1    1  4  8
2    2  2  9
Run Code Online (Sandbox Code Playgroud)
>>> df2 = pd.DataFrame({'grp':[1], 'x':[6], 'z':[3]})
>>> df2
   grp  x z
0    1  6 3
Run Code Online (Sandbox Code Playgroud)

我认为半连接可以用单列轻松完成,例如

>>> df1[df1.grp.isin(df2.grp)]
   grp  x  y
0    1  6  7
1    1  4  8
Run Code Online (Sandbox Code Playgroud)

问题是:如何使用两列 -grp和 来做到这一点x

pandas

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

将 std::bind 与 lambda 函数一起使用

以下代码无法编译:

auto greater_than = [](const int a, const int b) { return a > b; };
auto is_adult = bind(&greater_than, placeholders::_1, 17);
cout << "Age 19 is adult = " << is_adult(19) << endl;
Run Code Online (Sandbox Code Playgroud)

is_adult呼叫是给一个模糊的错误:

error: no matching function for call to object of type 'std::_Bind<(lambda at main.cpp:62:23) *(std::_Placeholder<1>, int)>'
Run Code Online (Sandbox Code Playgroud)

但是,如果我将其移动greater_than为全局函数,则它可以工作。

这是为什么?

c++

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

如何在 UML 图中表示 C++ 私有继承?

在C ++中,可以创建通过一个子类publicprotectedprivate继承。在 UML 类图中表示这一点的符号是什么?我正在考虑在箭头上贴上标签,但不确定这是否是常见做法。

c++ inheritance uml class-diagram class

0
推荐指数
1
解决办法
147
查看次数