小编man*_*hon的帖子

numpy 4D 数组高级索引示例

我正在阅读一些深度学习代码。我对 numpy 数组中的高级索引有问题。我正在测试的代码:

import numpy

x = numpy.arange(2 * 8 * 3 * 64).reshape((2, 8, 3, 64))
x.shape

p1 = numpy.arange(2)[:, None]
sd = numpy.ones(2 * 64, dtype=int).reshape((2, 64))
p4 = numpy.arange(128 // 2)[None, :]

y = x[p1, :, sd, p4]
y.shape
Run Code Online (Sandbox Code Playgroud)

为什么形状y(2, 64, 8)

下面是上面代码的输出:

>>> x.shape
(2, 8, 3, 64)

>>> p1
array([[0], [1]])

>>> sd
array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy numpy-ndarray

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

c ++ fprintf只打印第一个字符串

我尝试使用以下代码:

String hi = "hi";
String bye = "bye";
fprintf(fileout, "%d: %s, %s", 10, hi, bye); //fail 
fprintf(fileout, "%d: %s, %s", 10, "hi", "bye");//ok
Run Code Online (Sandbox Code Playgroud)

但是,这不能写到文本文件.怎么了?

c++ printf

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

C#Thread.Sleep(1000)在某些电脑上花费的时间超过1000毫秒

我写ac#program倒计时5秒.我所做的是:

        new Task(() =>
        {

                try
                {
                        this.Invoke((Action)delegate()
                        {
                            label1.Text = "5"; // 4, 3, 2..etc
                        });
                    }
                    Thread.Sleep(1000);
                }
                catch
                {
                    // form could be disposed
                    break;
                }

            }

        }).Start();
Run Code Online (Sandbox Code Playgroud)

这可以在我的电脑上运行,但是,当我将程序复制到平板电脑时,Thread.Sleep(1000)给出的时间超过1秒.换句话说,从5,4,3,2,1更新标签需要5秒以上(实际上超过10秒).或者,更新label1.Text ="5"等需要很长时间?这对我来说没有意义.我想知道出了什么问题?

c# multithreading sleep timer

0
推荐指数
2
解决办法
1374
查看次数

标签 统计

arrays ×1

c# ×1

c++ ×1

multithreading ×1

numpy ×1

numpy-ndarray ×1

printf ×1

python ×1

sleep ×1

timer ×1