leezu commented on a change in pull request #18403:
URL: https://github.com/apache/incubator-mxnet/pull/18403#discussion_r434873959



##########
File path: python/mxnet/gluon/probability/distributions/distribution.py
##########
@@ -0,0 +1,196 @@
+# 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.
+
+# coding: utf-8
+# pylint: disable=wildcard-import
+"""Base distribution class."""
+__all__ = ['Distribution']
+
+from .utils import cached_property
+from numbers import Number
+
+
+class Distribution(object):
+    r"""Base class for distribution.
+    
+    Parameters
+    ----------
+    F : mx.ndarray or mx.symbol.numpy._Symbol
+        Variable that stores the running mode.
+    event_dim : int, default None
+        Variable indicating the dimension of the distribution's support.
+    validate_args : bool, default None
+        Whether to validate the distribution parameters
+    """          
+
+    # Variable indicating whether the sampling method has
+    # pathwise gradient.
+    has_grad = False
+    support = None
+    has_enumerate_support = False
+    arg_constraints = {}
+    _validate_args = False
+
+    @staticmethod
+    def set_default_validate_args(value):
+        if value not in [True, False]:
+            raise ValueError
+        Distribution._validate_args = value
+
+    def __init__(self, F=None, event_dim=None, validate_args=None):
+        self.F = F

Review comment:
       @xidulu the timeline of implementation does not have anything to do with 
ensuring that the final PR integrates well into the overall project. Have you 
actually taken a look at what steps I requested you to make? I don't think so. 
The aim of my code-review request here is to make sure that the code you PR is 
integrated correctly with the Gluon API. For this, you'll need to make a few 
high-level changes in the way the StochasticBlock is called. Specifically,
   
   - delete self.F = F
   - use def forward instead of def hybrid_foward
   - Change the checks of isinstance(Symbol) to checking if the Block is 
hybridized.
   
   These are mostly trivial changes, but I agree there will be an effort to 
check if any unexpected problems occur. This is nothing unexpected in the case 
of parallel feature development. The recommendation to start developing against 
the hybrid_forward API is based on the fact that both APIs are highly related 
and thus the effort of the final migration is low.
   
   From my perspective it's also fine to keep the F and target the 1.x branch 
in this PR. Then we may have a separate PR integrating into the master branch. 
Let me know if you prefer that and I'll be happy to do another review about any 
issues that the current PR may have with respect to the 1.x API.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to