-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add from_params
to Linear
& Conv
#7525
Conversation
from_params
to Linear & Convfrom_params
to Linear & Conv
I think this depends on #7531 somewhat. Any thoughts, @emcastillo? |
AFAIK #7531 just makes the initializers to allow chainerx arrays as arguments and disable the explicit fallback for random routines as chainerx now supports random (through chainerx internal fallback). In this PR the proposed |
Sorry for the lack of explanation. The motivation of this PR is to ease |
Sorry for the delay. This was already merged in #7687 so there shouldn't be issues now. |
Thanks for the info. I'll resume working. |
376d2d9
to
b97903b
Compare
Apologize for having been slow to work. |
'cuda:0', | ||
] | ||
})) | ||
class TestConvolutionNDFromParams(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a new Test case,
How about using the from_params in the create_link
of the ConvolutionND(testing.LinkTestCase)
main test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
Is this applicable to the other test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes,
rebase with the master branch so the new tests appear :)
You can ignore this suggestion if you dont feel comfortable with this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to rebase because some of the convolution tests changed some days ago.
Thanks!!
b97903b
to
1324b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the syntax error, once it is done I think it will be ready for CI.
Thanks!
assert link2.W.shape == link1.W.shape | ||
assert link2.b.shape == link2.b.shape | ||
assert link2.stride == link1.stride | ||
assert link2.pad = link1.pad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax error here, should be ==
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, accessed.
Another syntax error: |
d1003cc
to
ecdac19
Compare
Fix travis errors please. |
I'm sorry, but did the ci run as we expect the last time? |
there are several errors on travis |
|
||
link2 = convolution_nd.ConvolutionND.from_params( | ||
link1.W, link1.b, | ||
stride=self.stride, pad=self.pad, groups=self.group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groups=self.groups
I meant to say that some configuration of log display seemed to be changed since just there was only kind of "test failed" message first. |
|
||
link = cls( | ||
in_channels, out_channels, (kw, kh), stride, pad, nobias, | ||
initialW=variable.as_array(W), initial_bias=variable.as_array(b), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code fails when arrays other than numpy are passed as initializers.
Running your branch in my environment shows
Base test method: TestConvolution2D_use_chainerx_false__chainerx_device_None__use_cuda_true__cuda_device_0__use_cudnn_always__cudnn_deterministic_false__autotune_false__cudnn_fast_batch_normalization_false__use_ideep_never.test_from_params
E Test parameters:
E W_dtype: <class 'numpy.float64'>
E x_dtype: <class 'numpy.float64'>
E
E
E (caused by)
E TypeError: invalid type of initializer: <class 'cupy.core.core.ndarray'>
We can allow to use cupy/chainerx as a constant initializer (shouldnt be difficult)
but let us discuss it first!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just submitted a PR to tackle this issue #8022
@@ -187,4 +187,31 @@ def test_invalid_size(self): | |||
self.link(chainer.Variable(self.x)) | |||
|
|||
|
|||
@testing.parameterize(*testing.product({ | |||
'nobias': [True, False], | |||
'device': [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the devices, they are not being used in the test
'@cupy:0', | ||
'native:0', | ||
'cuda:0', | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
ecdac19
to
5e28c5f
Compare
Check CI errors |
ah, sphinx syntax error... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jenkins, test this please |
Ah...
|
Jenkins CI test (for commit 9ea1ca8, target branch master) failed with status FAILURE. |
Jenkins, test this please |
Jenkins CI test (for commit 8566494, target branch master) succeeded! |
from_params
to Linear & Convfrom_params
to Linear
& Conv
Jenkins CI test (for commit 8566494, target branch master) succeeded! |
This addresses #7042 & #7041 by showing draft implementations of some connection links that are commonly used.
The aim of this PR is easing initializing links from weights that are not easy to generate
chainer.Initializer
\s or that are trained beforehand in some way (e.g. word embedding vectors or a weight extracted from a pretrained model).Currently, users can pass those weights to
initialW
/initial_bias
if they are numpy.ndarray as a variant ofchainer.initializers.Constant
, but I don't think this manner intuitive.