我有一个类型的函数列表:
func_list = [lambda x: function1(input),
lambda x: function2(input),
lambda x: function3(input),
lambda x: x]
Run Code Online (Sandbox Code Playgroud)
和形状数组 [4, 200, 200, 1](一批图像)。
我想沿第 0 轴按顺序应用函数列表。
编辑:重新表述问题。这相当于上面的。说,而不是数组,我有一个由 4 个相同数组组成的元组,形状为 (200, 200, 1),我想在第一个元素上应用 function1,在第二个元素上应用 function2,等等。这可以在没有的情况下完成吗? for 循环?
我有一个长度为 n 的音频信号,我想将它分成长度为 k 的窗口,重叠 r < k。我将从我的音频信号中获得多少个窗口?
我计算它是
n/(k-r) - r
Run Code Online (Sandbox Code Playgroud)
但我现在明白这是错误的。
我想用
np.random.randint(4, size=2)
Run Code Online (Sandbox Code Playgroud)
从0到3生成一对不同的随机数.问题是它有时给出(0,0),(3,3)等.是否有办法强制数字不同?
有一个像这样的数据框:
## +---+---+
## | id|num|
## +---+---+
## | 2|3.0|
## | 3|6.0|
## | 3|2.0|
## | 3|1.0|
## | 2|9.0|
## | 4|7.0|
## +---+---+
Run Code Online (Sandbox Code Playgroud)
我想删除连续的重复,并获得:
## +---+---+
## | id|num|
## +---+---+
## | 2|3.0|
## | 3|6.0|
## | 2|9.0|
## | 4|7.0|
## +---+---+
Run Code Online (Sandbox Code Playgroud)
我在 Pandas 中找到了执行此操作的方法,但在 Pyspark 中却没有找到。
因此,我查看了多处理模块的文档,也查看了此处提出的其他问题,但似乎没有一个与我的情况相似,因此我开始了一个新问题。
为了简单起见,我有一段如下形式的代码:
# simple dataframe of some users and their properties.
data = {'userId': [1, 2, 3, 4],
'property': [12, 11, 13, 43]}
df = pd.DataFrame.from_dict(data)
# a function that generates permutations of the above users, in the form of a list of lists
# such as [[1,2,3,4], [2,1,3,4], [2,3,4,1], [2,4,1,3]]
user_perm = generate_permutations(nr_perm=4)
# a function that computes some relation between users
def comp_rel(df, permutation, user_dict):
df1 = df.userId.isin(permutation[0])
df2 = df.userId.isin(permutation[1])
user_dict[permutation[0]] += permutation[1]
return user_dict
# and …
Run Code Online (Sandbox Code Playgroud) 我有以下结构:
----parent_branch
|
------ my_branch
Run Code Online (Sandbox Code Playgroud)
到目前为止,我一直在 my_branch 工作,并且在 parent_branch 中进行了重要更改。我只想将这些更改合并到 my_branch 中,而不会弄乱我在 my_branch 中所做的工作。我怎样才能安全地做到这一点?
我想用depthwise_conv2d从Tensorflow。据我所知,它为每个通道执行常规的2D卷积,每个卷积都有depth_multiplier
许多功能。
然后,如果depth_multiplier = 1
,我应该期望输入通道的数量与输出通道的数量相同。但是为什么我可以有256个输入通道和512个输出通道?额外渠道从何而来?
我想.txt
用我的环境正在使用的所有 python 包创建一个文件,并将其包含在 git repo 中,以便任何需要运行代码的人都可以创建一个环境,安装列表中的所有包并使用它.
我有两个问题,首先,如何.txt
使用所有已安装的软件包创建该文件?其次,拥有该.txt
文件的人如何在其全新的 anaconda 环境中安装其中的所有内容(使用 pip3?)?
我有两个列表,例如:
lst1 = [0, 2, 4, 5, 5, 6, 5, 2]
lst2 = [1, 3, 7, 9, 9, 11, 8, 3]
Run Code Online (Sandbox Code Playgroud)
对于相同索引的元素,我想计算它们在一起出现的次数,因此结果应该类似于字典:
{ [0, 1] : 1,
[2, 3] : 2,
[4, 7] : 1,
[5, 9] : 2,
[6, 11] : 1,
[5, 8] : 1 }
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点而无需循环,可以很好地扩展?我需要针对非常大的列表(每个〜20k元素)运行它。
python ×4
python-3.x ×3
numpy ×2
anaconda ×1
apache-spark ×1
arrays ×1
convolution ×1
dictionary ×1
function ×1
git ×1
github ×1
list ×1
math ×1
overlap ×1
pip ×1
pyspark ×1
pytorch ×1
random ×1
set ×1
statistics ×1
tensorflow ×1