How to use actions method in Selene

Best Python code snippet using selene_python

centralized_categorical_lstm_policy.py

Source:centralized_categorical_lstm_policy.py Github

copy

Full Screen

...130 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask131 masked_probs = masked_probs / masked_probs.sum(axis=-1, keepdims=True) # renormalize132 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution133 return masked_dists_n134 def get_actions(self, obs_n, avail_actions_n, greedy=False):135 """Independent agent actions (not using an exponential joint action space)136 137 Args:138 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]139 E.g. 3 agents: [o1, o2, o3]140 """141 with torch.no_grad():142 dists_n = self.step_forward(obs_n, avail_actions_n)143 if not greedy:144 actions_n = dists_n.sample().numpy()145 else:146 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)147 agent_infos_n = {}148 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...

Full Screen

Full Screen

dec_categorical_lstm_policy.py

Source:dec_categorical_lstm_policy.py Github

copy

Full Screen

...129 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask130 masked_probs = masked_probs / masked_probs.sum(axis=-1, keepdims=True) # renormalize131 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution132 return masked_dists_n133 def get_actions(self, obs_n, avail_actions_n, greedy=False):134 """Independent agent actions (not using an exponential joint action space)135 136 Args:137 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]138 E.g. 3 agents: [o1, o2, o3]139 """140 with torch.no_grad():141 dists_n = self.step_forward(obs_n, avail_actions_n)142 if not greedy:143 actions_n = dists_n.sample().numpy()144 else:145 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)146 agent_infos_n = {}147 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...

Full Screen

Full Screen

dicg_ce_categorical_lstm_policy.py

Source:dicg_ce_categorical_lstm_policy.py Github

copy

Full Screen

...118 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask119 masked_probs = masked_probs / masked_probs.sum(axis=-1, keepdims=True) # renormalize120 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution121 return masked_dists_n, attention_weights122 def get_actions(self, obs_n, avail_actions_n, greedy=False):123 """Independent agent actions (not using an exponential joint action space)124 125 Args:126 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]127 E.g. 3 agents: [o1, o2, o3]128 """129 with torch.no_grad():130 dists_n, attention_weights = self.step_forward(obs_n, avail_actions_n)131 if not greedy:132 actions_n = dists_n.sample().numpy()133 else:134 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)135 agent_infos_n = {}136 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...

Full Screen

Full Screen

tree-massactions.test.js

Source:tree-massactions.test.js Github

copy

Full Screen

...22 });23 });24 describe('check initObservable', function () {25 it('by default will set visible for all action where exist actions', function () {26 expect(model.actions()[0].visible).toBeDefined();27 expect(model.actions()[0].visible()).toBeFalsy();28 });29 it('check when actions is absent', function () {30 model.actions([{31 type: 'delete'32 }]);33 model.initObservable();34 expect(model.actions()[0].visible).toBeUndefined();35 });36 it('check nested level actions', function () {37 model.actions()[0].actions[0].actions = [{38 type: 'delete'39 }];40 model.initObservable();41 expect(model.actions()[0].actions[0].visible).toBeDefined();42 expect(model.actions()[0].actions[0].visible()).toBeFalsy();43 });44 it('check reference to parent object', function () {45 expect(model.actions()[0].parent).toBe(model.actions());46 });47 });48 describe('check recursiveObserveActions', function () {49 it('set visible for all action where exist actions', function () {50 var actions = [{51 type: 'availability',52 actions: [{53 type: 'delete'54 }]55 }];56 model.recursiveObserveActions(actions);57 expect(actions[0].visible).toBeDefined();58 expect(actions[0].visible()).toBeFalsy();59 });60 it('check when actions is absent', function () {61 var actions = [{62 type: 'delete'63 }];64 model.recursiveObserveActions(actions);65 expect(actions[0].visible).toBeUndefined();66 });67 it('check nested level actions', function () {68 var actions = [{69 type: 'availability',70 actions: [{71 type: 'delete',72 actions: [{73 type: 'safely'74 }]75 }]76 }];77 model.recursiveObserveActions(actions);78 expect(actions[0].actions[0].visible).toBeDefined();79 expect(actions[0].actions[0].visible()).toBeFalsy();80 });81 it('check reference to parent object', function () {82 var actions = [{83 type: 'availability',84 actions: [{85 type: 'delete'86 }]87 }];88 model.recursiveObserveActions(actions);89 expect(actions[0].parent).toBe(actions);90 });91 });92 it('check getAction', function () {93 expect(model.getAction('availability')).toBe(model.actions()[0]);94 expect(model.getAction('availability.enable')).toBe(model.actions()[0].actions[0]);95 expect(model.getAction('absent')).toBeFalsy();96 });97 describe('check hideSubmenus', function () {98 it('with class actions', function () {99 model.actions()[0].visible(true);100 expect(model.actions()[0].visible()).toBeTruthy();101 model.hideSubmenus();102 expect(model.actions()[0].visible()).toBeFalsy();103 });104 it('with another object', function () {105 var actions = model.actions();106 actions[0].visible(true);107 expect(actions[0].visible()).toBeTruthy();108 model.hideSubmenus(actions);109 expect(actions[0].visible()).toBeFalsy();110 });111 });112 describe('check applyAction', function () {113 it('change visibility of submenu', function () {114 expect(model.actions()[0].visible()).toBeFalsy();115 expect(model.applyAction('availability')).toBe(model);116 expect(model.actions()[0].visible()).toBeTruthy();117 });118 });119 });...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful