Operators
The following symbolic operators are supported on layers:
| Symbol | Operator |
|---|---|
| + | add |
| - | subtract |
| * | multiply |
| / | division |
| // | floor division |
| % | mod |
| ^ | power |
| == | equal |
| != | not equal |
| < | less than |
| <= | less than or equal |
| > | greater than |
| >= | greater than or equal |
| & | logical and |
| | | logical or |
On a layer you can also invoke the following operations using layer.operator(...) syntax:
| Operator |
|---|
| abs |
| ceil |
| clip |
| conv2d |
| exp |
| exp2 |
| floor |
| isin |
| isnan |
| log |
| log10 |
| log2 |
| nan_to_num |
You can also call the following methods from yirgacheffe:
abs = LayerOperation.abs
module-attribute
ceil = LayerOperation.ceil
module-attribute
exp = LayerOperation.exp
module-attribute
exp2 = LayerOperation.exp2
module-attribute
floor = LayerOperation.floor
module-attribute
isin = LayerOperation.isin
module-attribute
log = LayerOperation.log
module-attribute
log10 = LayerOperation.log10
module-attribute
log2 = LayerOperation.log2
module-attribute
nan_to_num = LayerOperation.nan_to_num
module-attribute
round = LayerOperation.round
module-attribute
maximum(a, b)
Element-wise maximum of layer elements.
Behaves like numpy.maximum(x1, x2), comparing two layers element-by-element and returning a new layer with the maximum values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
First layer or constant to compare. |
required | |
b
|
Second layer or constant to compare. |
required |
Returns:
| Type | Description |
|---|---|
|
New layer representing the element-wise maximum of the inputs. |
minimum(a, b)
Element-wise minimum of layer elements.
Behaves like numpy.minimum(x1, x2), comparing two layers element-by-element and returning a new layer with the minimum values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
First layer or constant to compare. |
required | |
b
|
Second layer or constant to compare. |
required |
Returns:
| Type | Description |
|---|---|
|
New layer representing the element-wise minimum of the inputs. |
where(cond, a, b)
Return elements chosen from a or b depending on cond.
Behaves like numpy.where(condition, x, y), returning a layer operation
where elements from a are selected where cond is True, and elements
from b are selected where cond is False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cond
|
Layer or constant used as condition. Where True, yield |
required | |
a
|
Layer or constant with values from which to choose where |
required | |
b
|
Layer or constant with values from which to choose where |
required |
Returns:
| Type | Description |
|---|---|
|
New layer representing the conditional selection. |