Search Unity

Question Simple ML model using OSC not improving

Discussion in 'ML-Agents' started by carlosm, Oct 9, 2022.

  1. carlosm

    carlosm

    Joined:
    Sep 17, 2015
    Posts:
    7
    Hi, mlagents newbie here. I'm trying to send frequency numbers as discrete actions via osc to an external software. These frequency values control one cutoff frequency on an EQ that changes levels on output freq bands. I started testing from 800Hz to 1.2kHz to target 1kHz which outputs levels between -7 and 11 which are sent back to unity to set rewards. Basically, the model should find the frequency that boosts the level of the 1kHz band. Branch size =400
    Reward to No-reward ratio is 1:7. Any help would be appreciate it.

    public override void CollectObservations(VectorSensor sensor)
    {
    sensor.AddObservation(meanValue);
    sensor.AddObservation(micFreq);
    }
    // Start is called before the first frame update
    public override void OnActionReceived(ActionBuffers actions)
    {
    micFreq = actions.DiscreteActions[0] + 800;
    var MicFreq = new OSCMessage(_micFreq);
    MicFreq.AddValue(OSCValue.Int(micFreq));
    Transmitter.Send(MicFreq);
    }
    private void Update()
    {
    Receiver.Bind(_meanRec, ReceivedMessage);
    //Debug.Log(meanValue);
    if (-7f > meanValue && meanValue > -11f) {
    SetReward(1f);
    EndEpisode();
    Debug.Log("reward");
    }
    else
    {
    SetReward(0.1f);
    EndEpisode();
    Debug.Log("NO - reward");
    }
     

    Attached Files: