def test_make_subgoals(): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, None, learn_goal_velocities=True) dmp_seq.init(3, 3) assert_equal(len(dmp_seq.subgoals), 4)
def test_make_n_features(): execution_times = [0.2, 0.3, 0.5] subgoals = [[0], [0.5], [1.0], [2]] dmp_seq = DMPSequence(3, execution_times, 0.01, None, subgoals, learn_goal_velocities=True) dmp_seq.init(3, 3) assert_array_almost_equal(dmp_seq.n_features, [50, 50, 50])
def test_make_execution_times(): n_features = [5, 5, 5] subgoals = [[0], [0.5], [1.0], [2]] dmp_seq = DMPSequence(3, None, 0.01, n_features, subgoals, learn_goal_velocities=True) dmp_seq.init(3, 3) assert_array_almost_equal(dmp_seq.execution_times, [1, 1, 1])
def test_initial_weights(): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] subgoals = [[0], [0.5], [1.0], [2]] initial_weights = [np.ones(5), np.ones(5), np.ones(5)] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=True, initial_weights=initial_weights) dmp_seq.init(3, 3) assert_equal(len(dmp_seq.weights), 3)
def test_dimensions_mismatch(): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] subgoals = [[0], [0.5], [1.0], [2]] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=True) assert_raises_regexp(ValueError, "Input and output dimensions", dmp_seq.init, 3, 4)
def test_empty_metaparameters(): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] subgoals = [[0], [0.5], [1.0], [2]] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=True) dmp_seq.init(3, 3) dmp_seq.set_meta_parameters([], [])
def create_dmp_seq(n_task_dims=1): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] subgoals = [[0] * n_task_dims, [0.5] * n_task_dims, [1.0] * n_task_dims, [2] * n_task_dims] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=True) dmp_seq.init(3 * n_task_dims, 3 * n_task_dims) dmp_seq.set_meta_parameters(["x0", "g"], [np.zeros(n_task_dims), 2 * np.ones(n_task_dims)]) return dmp_seq, subgoals
def test_n_params(): execution_times = [0.2, 0.3, 0.5] n_features = [5, 5, 5] subgoals = [[0], [0.5], [1.0], [2]] initial_weights = [np.ones(5), np.ones(5), np.ones(5)] dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=True, initial_weights=initial_weights) dmp_seq.init(3, 3) assert_equal(len(dmp_seq.get_params()), 3 * 5 + 2 * 1 + 4 * 1) assert_equal(dmp_seq.get_n_params(), 3 * 5 + 2 * 1 + 4 * 1) dmp_seq.set_params(dmp_seq.get_params()) dmp_seq = DMPSequence(3, execution_times, 0.01, n_features, subgoals, learn_goal_velocities=False, initial_weights=initial_weights) dmp_seq.init(3, 3) assert_equal(len(dmp_seq.get_params()), 3 * 5 + 2) assert_equal(dmp_seq.get_n_params(), 3 * 5 + 2) dmp_seq.set_params(dmp_seq.get_params())
def test_no_dimensions(): dmp_seq = DMPSequence() dmp_seq.init(0, 0) dmp_seq.set_meta_parameters([], []) io = np.empty(0) dmp_seq.set_inputs(io) dmp_seq.step() dmp_seq.get_outputs(io)