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



##########
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 
   
   > To summarize, the F in the distribution object does not violate the 2.x 
API. Instead, it can fit well into both 1.x and 2.x API.
   
   Note that the Gluon.HybridBlock in the master branch currently implements 
both forward and hybrid_forward for transition purpose. The hybrid_forward is 
deprecated and will be deleted from all HybridBlocks prior to the release. 
There was just too many code relying on the deprecated interface to delete it 
outright. This doesn't mean we should add more code relying on the deprecated 
interface.
   
   Specifically, the `getF` function used in the StochasticBlock would never 
see a symbolic input. Thus part of the code in your PR can be simplified / 
updated. Sorry if this background to my previous comment wasn't completely 
clear.




----------------------------------------------------------------
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