How to use get_kernels method in autotest

Best Python code snippet using autotest_python

simulate.py

Source:simulate.py Github

copy

Full Screen

...168 df.to_pickle(f'results/predicted/{hostname}_{kernel}.pkl.gz')169 print(f"saved {filename}")170 return data171def simulate_host(hostname, kernels=None):172 kernels_args = get_kernels(hostname=hostname)173 if kernels is not None:174 kernels_args = [(kn, ka) for kn, ka in kernels_args if kn in kernels]175 for kernel, args in get_kernels(hostname=hostname):176 if kernels is not None and kernel not in kernels:177 continue178def main():179 hosts = get_hostnames()180 if len(sys.argv) > 1:181 if any([h in sys.argv for h in get_hostnames()]):182 hosts = [h for h in get_hostnames() if h in sys.argv]183 if '--serial' in sys.argv:184 for hostname in hosts:185 kernels = get_kernels(hostname=hostname)186 if any([kn in sys.argv for kn, ka in get_kernels(hostname=hostname)]):187 kernels = [(kn, ka) for kn, ka in get_kernels(hostname=hostname) if kn in sys.argv]188 for kernel, args in kernels:189 simulate(hostname, kernel, args)190 else:191 with mp.Pool() as p:192 for hostname in hosts:193 kernels = get_kernels(hostname=hostname)194 if any([kn in sys.argv for kn, ka in get_kernels(hostname=hostname)]):195 kernels = [(kn, ka) for kn, ka in get_kernels(hostname=hostname) if kn in sys.argv]196 if '--serial' in sys.argv:197 for kernel, args in kernels:198 simulate(hostname, kernel, args)199 else:200 p.starmap_async(simulate, [(hostname, kernel, args) for kernel, args in kernels])201 p.close()202 p.join()203if __name__ == "__main__":...

Full Screen

Full Screen

word_sets.py

Source:word_sets.py Github

copy

Full Screen

...15 else:16 return 0.171819def get_kernels(phi):20 """21 :param phi: topics-words matrix, shape T x W, stochastic over W22 :return: list of kernels for each topic2324 kernel of the topic t is the set of the words w such that phi[t, w] > 1 / W25 """26 T, W = phi.shape27 return [28 set(np.where(phi[t, :] * W > 1)[0])29 for t in range(T)30 ]313233def get_top_words(phi, top_size):34 """35 :param phi: topics-words matrix, shape T x W, stochastic over W36 :param top_size: the size of the top37 :return: list of top words for each topic3839 top words is the set of words w of the largest top_size phi[t, w]40 of the topic41 """42 return [43 set(values)44 for values in np.argpartition(phi, -top_size, axis=1)[:, -top_size:]45 ]464748def calc_kernels_sizes(phi):49 """50 :param phi: topics-words matrix, shape T x W, stochastic over W51 :return: kernel sizes of the topics5253 kernel of the topic t is the set of the words w such that phi[t, w] > 1 / W54 """55 return [len(kernel) for kernel in get_kernels(phi)]565758def calc_avg_pairwise_jaccards(sets):59 """60 :param sets: list of sets61 :return: average jaccard distance between these sets62 """63 size = len(sets)64 res = 0.65 for i in range(size):66 for j in range(size):67 if i != j:68 res += calc_jaccard_distance(sets[i], sets[j])69 return res / size / (size - 1)707172def calc_avg_pairwise_kernels_jaccards(phi):73 """74 :param phi: topics-words matrix, shape T x W, stochastic over W75 :return: average pairwise jaccard distance of the topics' kernels7677 kernel of the topic t is the set of the words w such that phi[t,w] > 1 / W78 """79 return calc_avg_pairwise_jaccards(get_kernels(phi))808182def calc_avg_top_words_jaccards(phi, top_size):83 """84 :param phi: topics-words matrix, shape T x W, stochastic over W85 :param top_size: the size of the top86 :return: average pairwise jaccard distance of the topics' tops87 """ ...

Full Screen

Full Screen

RBF.py

Source:RBF.py Github

copy

Full Screen

...6 def __init__(self):7 layer.__init__(self)8 def init_kernels(self, numOfConnections):9 self.kernels = uniform.init_kernels(numOfConnections)10 def get_kernels(self):11 return self.kernels12 def get_params(self):13 return [self.get_kernels()]14 def connect(self, *layers):15 assert len(layers) == 116 self.intputShape = layers[0].get_outputShape()17 self.set_inputTensor( layers[0].get_outputTensor() )18 self.init_kernels( self.get_inputShape()[1] ) #assume inputShape is 1D19 outputTensor = self.get_RBFTensor()20 self.set_outputTensor( outputTensor )21 def get_inputShape(self):22 return self.intputShape23 def get_outputShape(self):24 return (1, 1)25 def verify_shape(self):26 pass27 def get_RBFTensor(self):28 '''29 Subclass should modify this to return a tensor indicating the function it uses as the base function30 '''31 raise NotImplementedError()32class fixedRBFLayer(RBFLayer):33 '''34 Uses user defined kernels and during the training, the kernels are not changed35 However, the computation may report an mis-match error if user defined kernels with wrong shape36 '''37 def __init__(self, kernels):38 RBFLayer.__init__(self)39 self.kernels = kernels40 def init_kernels(self, numOfConnections):41 '''42 Ignore the input43 '''44 pass45 def get_params(self):46 return None47class GassinRBFLayer(RBFLayer):48 def __init__(self):49 RBFLayer.__init__(self)50 def get_RBFTensor(self):51 return ( T.pow( self.get_kernels() - self.get_inputTensor(), 2 ) ).sum()52class fixedGassinRBFLayer(fixedRBFLayer):53 def __init__(self, kernels):54 fixedRBFLayer.__init__(self, kernels)55 def get_RBFTensor(self):...

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 autotest 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