Conversation
kohr-h
left a comment
There was a problem hiding this comment.
Certainly a nice addition. Just docs fall a bit short IMO, sometimes -- in particular if someone is not familiar with tf -- it's a bit guesswork as to what the functions actually do.
| __all__ = ('leaky_relu', 'prelu') | ||
|
|
||
|
|
||
| def leaky_relu(_x, alpha=0.2, name='leaky_relu'): |
There was a problem hiding this comment.
Established name?
Reason for the underscore(s) in _x?
Doc?
There was a problem hiding this comment.
The name is established, fixing x
| if padding in ('SAME', 'VALID'): | ||
| return tf.nn.conv2d(x, W, | ||
| strides=strides, padding=padding) | ||
| else: |
There was a problem hiding this comment.
Kind of strange logic to go into this case for whatever input except 'SAME' or 'VALID' comes in.
| padding=padding) | ||
|
|
||
|
|
||
| def conv1dtransp(x, W, stride=1, out_shape=None, padding='SAME'): |
There was a problem hiding this comment.
Is this convolving with the flipped kernel? It's a bit hard to imagine what "transposed convolution" is supposed to mean in 1d.
There was a problem hiding this comment.
Transpose of the convolution operator, e.g. adjoint.
This is standard nomenclature in the field
There was a problem hiding this comment.
I'm baffled that tensorflow has no implementation for that. 🤔
| strides=strides, padding='VALID') | ||
|
|
||
|
|
||
| def conv2dtransp(x, W, stride=(1, 1), out_shape=None, padding='SAME'): |
There was a problem hiding this comment.
Reason to deviate from the TF naming scheme?
| Parameters | ||
| ---------- | ||
| x : `tf.Tensor` with shape ``(B, L, C)`` or ``(B, H, W, C)`` | ||
| The input vector/image |
| else: | ||
| raise RuntimeError('unknown activation') | ||
|
|
||
| def apply_conv(x, nout, |
|
|
||
| return out | ||
|
|
||
| def apply_convtransp(x, nout, |
|
|
||
| return out | ||
|
|
||
| def apply_maxpool(x): |
| if __name__ == '__main__': | ||
| from dipp.util.testutils import run_doctests | ||
| with tf.Session(): | ||
| run_doctests() |
There was a problem hiding this comment.
You may want to add extraglobs={'tf': tf} here as well as to the add_doctest_modules in pytest_plugins.py.
| # v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
| # obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| import tensorflow as tf |
There was a problem hiding this comment.
Commenting here. In general, at least a minimal docstring that says what the function/class does would be great.
Monster commit basically moving most
adlerfunctionality intodipp