def _sum_deterministic_policy(self, model_names, path): net = core.Net('DeterministicPolicy') C2.set_net(net) output = 'ActionProbabilities' workspace.FeedBlob(output, np.array([1.0])) model_outputs = [] for model in model_names: model_output = '{}_Output'.format(model) workspace.FeedBlob(model_output, np.array([1.0], dtype=np.float32)) model_outputs.append(model_output) max_action = C2.FlattenToVec( C2.ArgMax(C2.Transpose(C2.Sum(*model_outputs))) ) one_blob = C2.NextBlob('one') workspace.FeedBlob(one_blob, np.array([1.0], dtype=np.float32)) C2.net().SparseToDense( [ max_action, one_blob, model_outputs[0], ], [output], ) meta = PredictorExportMeta( net, [one_blob], model_outputs, [output], ) save_to_db('minidb', path, meta)
def save_sum_deterministic_policy(model_names, path, db_type): net = core.Net("DeterministicPolicy") C2.set_net(net) output = "ActionProbabilities" workspace.FeedBlob(output, np.array([1.0])) model_outputs = [] for model in model_names: model_output = "{}_Output".format(model) workspace.FeedBlob(model_output, np.array([[1.0]], dtype=np.float32)) model_outputs.append(model_output) max_action = C2.FlattenToVec(C2.ArgMax(C2.Transpose(C2.Sum(*model_outputs)))) one_blob = C2.NextBlob("one") workspace.FeedBlob(one_blob, np.array([1.0], dtype=np.float32)) C2.net().SparseToDense([max_action, one_blob, model_outputs[0]], [output]) meta = PredictorExportMeta(net, [one_blob], model_outputs, [output]) save_to_db(db_type, path, meta)