Python Forum
server selects Runners from list and sends model
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
server selects Runners from list and sends model
#1
My goal is the server selects the number of runners from a list list1=[7, 9, 5, 0, 8] instead of integer value (5) to send to those runners only (7, 9, 5, 0, 8).

This is my Code which is works:

for runner in random.sample(runners, k=self.sample_size):
r_model = runner.optimise(self.intercept_, self.coef_, self.runner_hyperparams)
hyperparams = {
        'n_runners': 10,
        'sample_size': 5,
        'rounds': 1,
        'combine': 'weighted', # or 'mean'
        'partition_params': {
            'scheme': 'uniform'
        },
        'runner_hyperparams': {
            'epochs': 10,
            'lr': 0.15,
            'batch_size': 0
        }
    }
but when i trying to send to a list1,

hyperparams = {
    'n_runners': 10,
    'sample_size':list1,
    'rounds': 1,
    'combine': 'weighted', # or 'mean'
    'partition_params': {
        'scheme': 'uniform' # stratified, non-iidness, noise injection etc.
    },
    'runner_hyperparams': {
        'epochs': 10,
        'lr': 0.15,
        'batch_size': 0
    }
}
I am getting an IndexError, and not sure why?
Error:
TypeError: '<=' not supported between instances of 'int' and 'list'
Reply
#2
In random.sample(), k has to be a number. You're feeding it a list. If you want to feed it a number equal to the length of the list, convert it first.

for runner in random.sample(runners, k=len(self.sample_size)):
If for some reason sample_size is equal to runners, then just use random.shuffle() instead.
Reply
#3
Thanks a lot
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  model.fit and model.predict errors hatflyer 6 1,196 Nov-10-2023, 01:39 AM
Last Post: hatflyer
  how to make bot that sends instagram auto password reset code kraixx 2 1,283 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  How to take the tar backup files form remote server to local server sivareddy 0 1,871 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles Anldra12 10 5,680 Jun-11-2021, 04:48 PM
Last Post: snippsat
  Creating a list of RSSI value and send it to the server. Azuan 0 2,616 Jun-08-2020, 11:22 PM
Last Post: Azuan
  Python script Server list - if condition error razor04 12 5,073 Jan-27-2020, 09:05 PM
Last Post: razor04
  list of lists iterate only sends the last value batchenr 1 1,870 Sep-24-2019, 07:04 AM
Last Post: Gribouillis
  code that takes inputs for user name amounts etc and then sends custom message shaumyabrata 5 5,248 Feb-12-2017, 11:37 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020