def cost(self, **kwargs): y_hat = self.predict(**kwargs) y = tensor.concatenate( (kwargs["destination_latitude"][:, None], kwargs["destination_longitude"][:, None]), axis=1 ) return error.erdist(y_hat, y).mean()
def cost(self, **kwargs): y_hat = self.predict(**kwargs) y = tensor.concatenate((kwargs['destination_latitude'][:, None], kwargs['destination_longitude'][:, None]), axis=1) return error.erdist(y_hat, y).mean()
def cost_matrix(self, **kwargs): self.before_predict_all(kwargs) res = self.predict_all(**kwargs)[0] target = tensor.concatenate( (kwargs['destination_latitude'].dimshuffle('x', 0, 'x'), kwargs['destination_longitude'].dimshuffle('x', 0, 'x')), axis=2) target = target.repeat(kwargs['latitude'].shape[0], axis=0) ce = error.erdist(target.reshape((-1, 2)), res.reshape((-1, 2))) ce = ce.reshape(kwargs['latitude'].shape) return ce * kwargs['latitude_mask']
def cost_matrix(self, latitude, longitude, latitude_mask, **kwargs): latitude = latitude.T longitude = longitude.T latitude_mask = latitude_mask.T res = self.predict_all(latitude, longitude, latitude_mask, **kwargs)[0] target = tensor.concatenate( (kwargs['destination_latitude'].dimshuffle('x', 0, 'x'), kwargs['destination_longitude'].dimshuffle('x', 0, 'x')), axis=2) target = target.repeat(latitude.shape[0], axis=0) ce = error.erdist(target.reshape((-1, 2)), res.reshape((-1, 2))) ce = ce.reshape(latitude.shape) return ce * latitude_mask
def cost(self, **kwargs): (destination_hat, time_hat) = self.predict(**kwargs) destination = tensor.concatenate((kwargs['destination_latitude'][:, None], kwargs['destination_longitude'][:, None]), axis=1) time = kwargs['travel_time'] destination_cost = error.erdist(destination_hat, destination).mean() time_cost = error.rmsle(time_hat.flatten(), time.flatten()) self.add_auxiliary_variable(destination_cost, [roles.COST], 'destination_cost') self.add_auxiliary_variable(time_cost, [roles.COST], 'time_cost') return destination_cost + self.config.time_cost_factor * time_cost
def cost(self, **kwargs): (destination_hat, time_hat) = self.predict(**kwargs) destination = tensor.concatenate( (kwargs['destination_latitude'][:, None], kwargs['destination_longitude'][:, None]), axis=1) time = kwargs['travel_time'] destination_cost = error.erdist(destination_hat, destination).mean() time_cost = error.rmsle(time_hat.flatten(), time.flatten()) self.add_auxiliary_variable(destination_cost, [roles.COST], 'destination_cost') self.add_auxiliary_variable(time_cost, [roles.COST], 'time_cost') return destination_cost + self.config.time_cost_factor * time_cost