This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrafficSimulator_1Lane: | |
def __init__(self, initial_density, length, v_max, p_slow_down, random_v = False): | |
''' | |
Initialize the 1 lane traffic simulator object, also keep track of the flow density as a list | |
Args: | |
initial_density (float, between 0 and 1): the initial density of cars on the lane |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrafficSimulator_1Lane: | |
def __init__(self, initial_density, length, v_max, p_slow_down, random_v = False): | |
''' | |
Initialize the 1 lane traffic simulator object, also keep track of the flow density as a list | |
Args: | |
initial_density (float, between 0 and 1): the initial density of cars on the lane |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VAE(nn.Module): | |
def __init__(self, n_latent): | |
super(VAE, self).__init__() | |
self.fc1 = nn.Linear(784, 400) | |
self.fc21 = nn.Linear(400, n_latent) | |
self.fc22 = nn.Linear(400, n_latent) | |
self.fc3 = nn.Linear(n_latent, 400) | |
self.fc4 = nn.Linear(400, 784) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AE(nn.Module): | |
def __init__(self, n_latent): | |
super(AE, self).__init__() | |
self.encoder = nn.Sequential( | |
nn.Linear(28 * 28, 128), | |
nn.ReLU(True), | |
nn.Linear(128, 64), | |
nn.ReLU(True), | |
nn.Linear(64, n_latent)) | |
self.decoder = nn.Sequential( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average_prob(p1, p2, p3): | |
''' | |
Takes three different probability vectors in and outputs a randomly | |
sampled action from n_action with probability equals the average \ | |
probability of the input vectors | |
''' | |
a = range(n_action) | |
p = (p1 + p2 + p3)/3 | |
a = np.random.choice(a=a, p=p) | |
return a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average_prob(p1, p2, p3): | |
''' | |
Takes three different probability vectors in and outputs a randomly | |
sampled action from n_action with probability equals the average \ | |
probability of the input vectors | |
''' | |
a = range(n_action) | |
p = (p1 + p2 + p3)/3 | |
a = np.random.choice(a=a, p=p) | |
return a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def majority_vote(p1, p2, p3): | |
''' | |
Takes three different probability vectors in and outputs a randomly | |
sampled action from n_action according to majority voting scheme | |
''' | |
a = range(n_action) | |
a1 = np.random.choice(a=a, p=p1) | |
a2 = np.random.choice(a=a, p=p2) | |
a3 = np.random.choice(a=a, p=p3) | |
l = [a1, a2, a3] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder