- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
`使用 wave 模块分析 2GB WAV 文件(1khz 音调)音频丢失的最佳方法是什么?我尝试了下面的脚本
import wave
file1 = wave.open("testdropout.wav", "r")
file2 = open("silence.log", "w")
for i in xrange(file1.getnframes()):
frame = file1.readframes(i)
zero = True
for j in xrange(len(frame)):
# check if amplitude is greater than 0
# the ord() function converts the hex values to integers
if ord(frame[j]) > 0:
zero = False
break
if zero:
print >> file2, 'dropout at second %s' % (file1.tell()/file1.getframerate())
file1.close()
file2.close()
最佳答案
我以前没有使用过 wave
模块,但是 file1.readframes(i)
在第一帧时看起来像是在读取 1 帧,2当你在第二帧时是 10 帧,当你在第十帧时是 10 帧,而一个 2Gb CD 质量的文件可能有一百万帧 - 当你在帧 100,000 读取 100,000 帧时......越来越慢每次都通过循环吗?
根据我的评论,在 Python 2 中 range()
首先生成一个完整大小的内存数组,而 xrange()
不会,但不是完全使用 range 会更有帮助。
并使用 any()
将循环下推到较低层,以使代码更短,并可能更快:
import wave
file1 = wave.open("testdropout.wav", "r")
file2 = open("silence.log", "w")
chunksize = file1.getframerate()
chunk = file1.readframes(chunksize)
while chunk:
if not any(ord(sample) for sample in chunk):
print >> file2, 'dropout at second %s' % (file1.tell()/chunksize)
chunk = file1.readframes(chunksize)
file1.close()
file2.close()
这应该以 1 秒的 block 读取文件。
关于python - 使用 wave 模块在 2GB WAV 文件中搜索 dropouts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38706926/
我遇到过上述术语,但不确定它们之间的区别。 我的理解是 MC dropout 是正常的 dropout,它在测试期间也是活跃的,允许我们在多次测试运行中得到模型不确定性的估计。至于 channel-w
我正在从 deeplearning.ai 学习神经网络中的正则化类(class)。在 dropout 正则化中,教授说如果应用 dropout,计算的激活值将小于未应用 dropout 时(测试时)。
有两种方法可以执行dropout: torch.nn.Dropout torch.nn.function.Dropout 我问: 它们之间有区别吗? 我什么时候应该使用其中一种而不是另一种? 当我切换
根据此链接,keep_prob 的值必须在 (0,1] 之间: Tensorflow manual 否则我会得到值错误: ValueError: If keep_prob is not in (0,
我想在训练时从每个批处理的顺序 Keras 模型中的 dropout 层中提取并存储 dropout mask [1/0 数组]。我想知道在 Keras 中是否有一种直接的方法可以做到这一点,或者我是
来自 Keras 文档: dropout:在 0 和 1 之间 float 。要丢弃的单位分数 输入的线性变换。 recurrent_dropout:在 0 和 1 之间 float 。 drop 用
keras中的Dropout层与dropout和recurrent_droput参数有什么区别?它们都有相同的目的吗? 示例: model.add(Dropout(0.2)) # layer mod
我很困惑是使用 tf.nn.dropout 还是 tf.layers.dropout。 许多 MNIST CNN 示例似乎使用 tf.nn.droput,将 keep_prop 作为参数之一。 但它与
我目前正在尝试使用 Keras( tensorflow 后端)建立一个(LSTM)循环神经网络。我想使用带有 MC Dropout 的变分 dropout。我相信变分 dropout 已经通过 LST
tensorflow config dropout wrapper具有可以设置的三种不同的丢失概率:input_keep_prob、output_keep_prob、state_keep_prob。
tensorflow config dropout wrapper具有可以设置的三种不同的丢失概率:input_keep_prob、output_keep_prob、state_keep_prob。
我想在我的网络中添加 word dropout,以便我可以有足够的训练示例来训练“unk”标记的嵌入。据我所知,这是标准做法。假设unk token的索引为0,padding的索引为1(方便的话我们可
dropout 层只应该在模型训练期间使用,而不是在测试期间使用。 如果我的 Keras 序列模型中有一个 dropout 层,我是否需要在做之前做一些事情来删除或沉默它 model.predict(
我试图了解辍学对验证平均绝对误差(非线性回归问题)的影响。 无辍学 辍学率为 0.05 辍学率为 0.075 在没有任何 dropouts 的情况下,验证损失大于训练损失,如1所示。我的理解是,验证损
玩具回归示例。使用 dropout=0.0 这很好用并且成本降低了。使用 dropout=0.5 我得到错误: ValueError: Got num_leading_axes=1 for a 1-d
如何在训练期间更改 Dropout?例如 Dropout= [0.1, 0.2, 0.3] 我尝试将其作为列表传递,但我无法使其工作。 最佳答案 要在训练过程中改变 dropout 概率,您应该使用
我有一个用多个 LayerNormalization 层训练的模型,我不确定在激活 dropout 进行预测时简单的权重转移是否正常工作。这是我正在使用的代码: from tensorflow.ker
我正在训练一个带有 dropout 的神经网络。碰巧的是,当我将 dropout 从 0.9 减少到 0.7 时,训练数据数据的损失(交叉验证错误)也会减少。我还注意到,随着我减少 dropout 参
根据 Keras 文档,dropout 层在训练和测试阶段表现出不同的行为: Note that if your model has a different behavior in training
我已经在多个地方看到您应该在验证和测试阶段禁用 dropout,并且只在训练阶段保留它。有什么理由让这种情况发生吗?我一直找不到一个很好的理由,只是想知道。 我问的一个原因是因为我训练了一个带有 dr
我是一名优秀的程序员,十分优秀!