def __init__(self, rewards=default_rewards): #dummy initial values #fill shared variables with dummy values self.attributes = create_shared("X_attrs_data", np.zeros([1, 1]), 'uint8') self.categories = create_shared("categories_data", np.zeros([1, 1]), 'uint8') self.batch_size = self.attributes.shape[0] #"end_session_now" action end_action = T.zeros([self.batch_size, 1], dtype='uint8') #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([ self.attributes, self.categories, end_action, ], axis=1).astype(theano.config.floatX) #indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1] + self.categories.shape[1]) #last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1] - 1 self.rw = rewards
def __init__(self,batch_size = 10): n_attrs = 3 n_categories = 2 #fill shared variables with dummy values self.attributes = create_shared("X_attrs_data",np.zeros([batch_size,n_attrs]),'uint8') self.categories = create_shared("categories_data",np.zeros([batch_size,n_categories]),'uint8') self.batch_size = self.attributes.shape[0] #"end_session_now" action end_action = T.zeros([self.batch_size,1], dtype='uint8') #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([self.attributes, self.categories, end_action, ],axis=1).astype(theano.config.floatX) #indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1]+self.categories.shape[1] ) #last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1]-1 #fill in one data sample self.generate_new_data_batch(batch_size)
def __init__(self,rewards = default_rewards): #dummy initial values #fill shared variables with dummy values self.attributes = create_shared("X_attrs_data",np.zeros([1,1]),'uint8') self.categories = create_shared("categories_data",np.zeros([1,1]),'uint8') self.batch_size = self.attributes.shape[0] #"end_session_now" action end_action = T.zeros([self.batch_size,1], dtype='uint8') #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([self.attributes, self.categories, end_action, ],axis=1).astype(theano.config.floatX) #indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1]+self.categories.shape[1] ) #last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1]-1 self.rw = rewards
def __init__(self,rewards = default_rewards,min_occurences = 15,experiment_path=""): #data params self.experiment_path=experiment_path self.min_occurences=min_occurences #fill shared variables with dummy values self.attributes = create_shared("X_attrs_data",np.zeros([1,1]),'uint8') self.categories = create_shared("categories_data",np.zeros([1,1]),'uint8') self.batch_size = self.attributes.shape[0] #"end_session_now" action end_action = T.zeros([self.batch_size,1], dtype='uint8') #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([self.attributes, self.categories, end_action, ],axis=1).astype(theano.config.floatX) #indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1]+self.categories.shape[1] ) #last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1]-1 self.rw = rewards #dimensions data_attrs,data_cats,_ = self.get_dataset() env_state_shapes = (data_cats.shape[1]+data_attrs.shape[1]+1,) observation_shapes = (env_state_shapes[0] +2,) #the rest is default #init default (some shapes will be overloaded below BaseEnvironment.__init__(self, env_state_shapes, observation_shapes)
def __init__(self, rewards=default_rewards, min_occurences=15, experiment_path=""): #data params self.experiment_path = experiment_path self.min_occurences = min_occurences #fill shared variables with dummy values self.attributes = create_shared("X_attrs_data", np.zeros([1, 1]), 'uint8') self.categories = create_shared("categories_data", np.zeros([1, 1]), 'uint8') self.batch_size = self.attributes.shape[0] #"end_session_now" action end_action = T.zeros([self.batch_size, 1], dtype='uint8') #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([ self.attributes, self.categories, end_action, ], axis=1).astype(theano.config.floatX) #indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1] + self.categories.shape[1]) #last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1] - 1 self.rw = rewards #dimensions data_attrs, data_cats, _ = self.get_dataset() env_state_shapes = (data_cats.shape[1] + data_attrs.shape[1] + 1, ) observation_shapes = (env_state_shapes[0] + 2, ) #the rest is default #init default (some shapes will be overloaded below BaseEnvironment.__init__(self, env_state_shapes, observation_shapes, action_shapes=[tuple()])
def __init__(self): # fill shared variables with dummy values self.attributes = create_shared("X_attrs_data", np.zeros([10, n_attrs]), 'uint8') self.categories = create_shared("categories_data", np.zeros([10, n_categories]), 'uint8') self.batch_size = self.attributes.shape[0] # "end_session_now" action end_action = T.zeros([self.batch_size, 1], dtype='uint8') # concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([ self.attributes, self.categories, end_action, ], axis=1).astype(theano.config.floatX) # indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1] + self.categories.shape[1]) # last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1] - 1 # generate dummy data sample self.generate_new_data_batch(10) #fill in the shapes #single-element lists for states and observations observation_shapes = [int((self.joint_data.shape[1] + 2).eval())] env_state_shapes = [int(self.joint_data.shape[1].eval())] action_shapes = [ (), ] #use default dtypes: int32 for actions, floatX for states and observations BaseEnvironment.__init__( self, env_state_shapes, observation_shapes, action_shapes, )
def __init__(self): # fill shared variables with dummy values self.attributes = create_shared("X_attrs_data", np.zeros([10, n_attrs]), 'uint8') self.categories = create_shared("categories_data", np.zeros([10, n_categories]), 'uint8') self.batch_size = self.attributes.shape[0] # "end_session_now" action end_action = T.zeros([self.batch_size, 1], dtype='uint8') # concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([self.attributes, self.categories, end_action, ], axis=1).astype(theano.config.floatX) # indices self.category_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1] + self.categories.shape[1] ) # last action id corresponds to the "end session" action self.end_action_id = self.joint_data.shape[1] - 1 # generate dummy data sample self.generate_new_data_batch(10) #fill in the shapes #single-element lists for states and observations observation_shapes=[int((self.joint_data.shape[1] + 2).eval())] env_state_shapes=[int(self.joint_data.shape[1].eval())] action_shapes=[(),] #use default dtypes: int32 for actions, floatX for states and observations BaseEnvironment.__init__( self, env_state_shapes, observation_shapes, action_shapes, )
def __init__( self, rewards=default_rewards, ): #fill shared variables with dummy values self.attributes = create_shared("patient_attributes", np.zeros([1, 1]), 'float32') self.disease_stages = create_shared("disease_stage_indicator", np.zeros([1, 1]), 'uint8') self.batch_size = self.attributes.shape[0] #concatenate data and cast it to float to avoid gradient problems self.joint_data = T.concatenate([ self.attributes, self.disease_stages, ], axis=1).astype(theano.config.floatX) #indices self.terminal_action_ids = T.arange( self.attributes.shape[1], self.attributes.shape[1] + self.disease_stages.shape[1]) self.rw = rewards # dimensions data_attrs, data_cats, _ = self.get_dataset() n_actions = data_cats.shape[1] + data_attrs.shape[1] env_state_shapes = (n_actions + 1, ) observation_shapes = (data_attrs.shape[1] + 1 + n_actions, ) self.n_actions = n_actions # the rest is default # init default (some shapes will be overloaded below BaseEnvironment.__init__(self, env_state_shapes, observation_shapes)