speechbrain.utils.filter_analysis 模块
实现工具以建模和组合过滤属性,即计算窗口大小、步幅等的行为,这可能对某些用例(如流式处理)有用。
- Authors:
Sylvain de Langen 2024
摘要
类:
模拟随时间表现类似过滤器(例如卷积、滤波器组等)的某些东西的属性。 |
函数:
返回一系列堆叠过滤器的过滤属性。 |
参考
- class speechbrain.utils.filter_analysis.FilterProperties(window_size: int, stride: int = 1, dilation: int = 1, causal: bool = False)[source]
基础类:
object模拟随时间表现类似过滤器(例如卷积、滤波器组等)的某些事物的属性。
- window_size: int
过滤器的大小,即单个输出所依赖的输入帧数。除了扩张之外,假设窗口在连续的帧块上操作。
示例:
size = 3, stride = 3 out <-a-> <-b-> <-c-> in 1 2 3 4 5 6 7 8 9
- stride: int = 1
滤波器的步幅,即从一个输出帧到下一个输出帧跳过多少输入帧(无论窗口大小或扩张如何)。
示例:
size = 3, stride = 2 <-a-> <-b-> <-d-> out <-c-> in 1 2 3 4 5 6 7 8 9
- dilation: int = 1
过滤器的扩张率。一个窗口将考虑每第n个(n=扩张)输入帧。使用扩张时,过滤器仍将观察
size个输入帧,但窗口将跨越更多的帧。膨胀主要与“a trous”卷积相关。 默认的膨胀率为1,实际上不进行膨胀。
示例:
size = 3, stride = 1, dilation = 3 <-------> dilation - 1 == 2 skips a a a | b | b | b | | c | | c | | c | | | d | | d | | d | | | | e | | e | | .. in 1 2 3 4 5 6 7 8 9 10 .. <-> stride == 1
- causal: bool = False
过滤器是否是因果的,即输出帧是否仅依赖于过去的输入帧(具有较低或相等的索引)。
在某些情况下,例如一维卷积,这可以通过在将滤波器应用于输入张量之前,在滤波器的左侧插入填充来实现。
示例:
size = 3, stride = 1, causal = true <-e-> <-d-> <-c-> b-> a in 1 2 3 4 5
- static pointwise_filter() FilterProperties[source]
返回一个简单过滤器的过滤属性,该过滤器的输出帧仅依赖于其各自的输入帧。
- with_on_top(other, allow_approximate=True)[source]
考虑到过滤器链
other(self(x)),返回重新计算的结果过滤器的属性。- Parameters:
其他 (FilterProperties) – 与
self组合的过滤器。allow_approximate (bool, 可选) – 如果为
True(默认值),则结果属性可能是“悲观的”,并且在无法确定确切属性时,可能会表达错误的依赖关系而不是报错。 这种情况可能发生在堆叠非因果和因果过滤器时。 根据使用情况,这可能是可以接受的,但像has_overlap这样的函数可能会错误地开始返回True。
- Returns:
组合过滤器的属性。
- Return type:
- speechbrain.utils.filter_analysis.stack_filter_properties(filters, allow_approximate=True)[source]
返回一系列堆叠过滤器的过滤属性。 如果序列为空,则返回一个无操作过滤器(大小为1,步幅为1)。
- Parameters:
filters (FilterProperties | any) – 要组合的过滤器,例如
[a, b, c]表示c(b(a(x)))。 如果某个项不是FilterProperties的实例,则会尝试在其上调用.get_filter_properties()。allow_approximate (bool, 可选) – 参见
FilterProperties.with_on_top.
- Returns:
ret – 过滤器序列的属性
- Return type: