How to use the yarl.backend function in yarl

To help you get started, we’ve selected a few yarl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rlgraph / rlgraph / yarl / components / common / noise_components.py View on Github external
#
# 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.
# ==============================================================================

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from yarl import backend
from yarl.components import Component

if backend == 'tf':
    import tensorflow as tf


class NoiseComponent(Component):
    """
    A base class Component that takes an action input and outputs some noise value.

    API:
    ins:
        action (float): The action value input.
    outs:
        noise (float): The noise value to be added to the action.
    """
    def __init__(self, action_space, scope="noise", **kwargs):
        """
github rlgraph / rlgraph / yarl / components / common / noise_components / constant_noise.py View on Github external
#
# 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.
# ==============================================================================

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from yarl import backend
from yarl.components.common.noise_components.noise import NoiseComponent

if backend == 'tf':
    import tensorflow as tf


class ConstantNoise(NoiseComponent):
    """
    Simple constant noise component.
    """
    def __init__(self, value=0.0, scope="constant_noise", **kwargs):
        super(ConstantNoise, self).__init__(scope=scope, **kwargs)

        self.value = value

    def noise(self):
        if backend == "tf":
            return tf.constant(self.value)
github rlgraph / rlgraph / yarl / components / common / decay_components / exponential_decay.py View on Github external
def decay(self, time_steps_in_decay_window):
        if backend == "tf":
            import tensorflow as tf
            return tf.train.exponential_decay(self.from_, time_steps_in_decay_window, self.half_life_timesteps, 0.5)
github rlgraph / rlgraph / yarl / components / common / decay_components / polynomial_decay.py View on Github external
def decay(self, time_steps_in_decay_window):
        if backend == "tf":
            import tensorflow as tf
            return tf.train.polynomial_decay(self.from_, time_steps_in_decay_window, self.num_timesteps,
                                             self.to_, power=self.power)