You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/30 20:11:29 UTC

[GitHub] safrooze commented on a change in pull request #13735: update wavenet codes

safrooze commented on a change in pull request #13735: update wavenet codes
URL: https://github.com/apache/incubator-mxnet/pull/13735#discussion_r252419590
 
 

 ##########
 File path: example/gluon/wavenet/models.py
 ##########
 @@ -0,0 +1,118 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Module: WaveNet network modulep
+"""
+from mxnet import nd
+from mxnet.gluon import nn
+import mxnet.ndarray as F
+# pylint: disable=invalid-name, too-many-arguments, arguments-differ, attribute-defined-outside-init, too-many-instance-attributes, invalid-sequence-index, no-self-use
+class One_Hot(nn.Block):
+    """
+    Description : generate one hot result
+    """
+    def __init__(self, depth):
+        super(One_Hot, self).__init__()
+        self.depth = depth
+
+    def forward(self, X_in):
+        with X_in.context:
+            X_in = X_in
+            self.ones = nd.one_hot(nd.arange(self.depth), self.depth)
+            return self.ones[X_in, :]
+
+    def __repr__(self):
+        return self.__class__.__name__ + "({})".format(self.depth)
+
+class WaveNet(nn.Block):
 
 Review comment:
   You cannot use index operator with hybridization. You need to use F.slice(). Also shape is not available with hybridized networks. You have three options:
   1. use padding so that output is the same size as input
   2. calculate the amount to slice by doing the math (a function of kernel size and dilation)
   3. use `sym.infer_shape()` to infer shape of the output in hybridized mode.
   
   I recommend option 2.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services