<commit_before>import numpy as np

from mushroom.algorithms.policy_search import REINFORCE
from mushroom.approximators.parametric import LinearApproximator
from mushroom.approximators.regressor import Regressor
from mushroom.core.core import Core
from mushroom.environments import ShipSteering
from mushroom.features.basis import GaussianRBF
from mushroom.features.features import Features
from mushroom.features.tensors import gaussian_tensor
from mushroom.policy import GaussianPolicy
from mushroom.utils.dataset import compute_J
from mushroom.utils.parameters import Parameter, AdaptiveParameter


def experiment(n_iterations, n_runs, ep_per_run, use_tensorflow):
    np.random.seed()

    # MDP
    mdp = ShipSteering()

    # Policy
    if use_tensorflow:
        tensor_list = gaussian_tensor.generate([3, 3, 6, 2],
                                               [[0., 150.],
                                                [0., 150.],
                                                [-np.pi, np.pi],
                                                [-np.pi / 12, np.pi / 12]])

        phi = Features(tensor_list=tensor_list, name='phi',
                       input_dim=mdp.info.observation_space.shape[0])
    else:
        basis = GaussianRBF.generate([3, 3, 6, 2],
                                     [[0., 150.],
                                      [0., 150.],
                                      [-np.pi, np.pi],
                                      [-np.pi / 12, np.pi / 12]])

        phi = Features(basis_list=basis)

    input_shape = (phi.size,)
    shape = input_shape + mdp.info.action_space.shape

    approximator_params = dict(params_shape=shape)
    approximator = Regressor(LinearApproximator, input_shape=input_shape,
                             output_shape=mdp.info.action_space.shape,
                             params=approximator_params)
    sigma = Parameter(value=.05)
    policy = GaussianPolicy(mu=approximator, sigma=sigma)<commit_msg>removed useless shape in ship steering<commit_after>import numpy as np

from mushroom.algorithms.policy_search import REINFORCE
from mushroom.approximators.parametric import LinearApproximator
from mushroom.approximators.regressor import Regressor
from mushroom.core.core import Core
from mushroom.environments import ShipSteering
from mushroom.features.basis import GaussianRBF
from mushroom.features.features import Features
from mushroom.features.tensors import gaussian_tensor
from mushroom.policy import GaussianPolicy
from mushroom.utils.dataset import compute_J
from mushroom.utils.parameters import Parameter, AdaptiveParameter


def experiment(n_iterations, n_runs, ep_per_run, use_tensorflow):
    np.random.seed()

    # MDP
    mdp = ShipSteering()

    # Policy
    if use_tensorflow:
        tensor_list = gaussian_tensor.generate([3, 3, 6, 2],
                                               [[0., 150.],
                                                [0., 150.],
                                                [-np.pi, np.pi],
                                                [-np.pi / 12, np.pi / 12]])

        phi = Features(tensor_list=tensor_list, name='phi',
                       input_dim=mdp.info.observation_space.shape[0])
    else:
        basis = GaussianRBF.generate([3, 3, 6, 2],
                                     [[0., 150.],
                                      [0., 150.],
                                      [-np.pi, np.pi],
                                      [-np.pi / 12, np.pi / 12]])

        phi = Features(basis_list=basis)

    input_shape = (phi.size,)

    approximator_params = dict(params_shape=shape)
    approximator = Regressor(LinearApproximator, input_shape=input_shape,
                             output_shape=mdp.info.action_space.shape,
                             params=approximator_params)
    sigma = Parameter(value=.05)
    policy = GaussianPolicy(mu=approximator, sigma=sigma)
{'fraction_non_alphanumeric': 0.0878086026978875, 'fraction_numerical': 0.017816238228556883, 'mean_word_length': 1.8071428571428572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5868122', 'n_tokens_mistral': 1113, 'n_tokens_neox': 989, 'n_words': 231}