This file contains 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
# | |
# Main data transformation part for Export-Import flow stacked bar | |
# | |
# Loop over paper types to create the export and import column data sources | |
data_to_dict = [('country', countries)] | |
for item in items_names: | |
d8 = df.loc[df['Item'] == item] | |
d8_exp = d8.loc[d8['Element'] == 'Export Quantity'] | |
d8_imp = d8.loc[d8['Element'] == 'Import Quantity'] |
This file contains 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
# | |
# Inner loop to draw trace of disk of import/export fraction | |
# | |
# Create Bokeh figure | |
p = figure(plot_width=650, plot_height=500, toolbar_location='above') | |
# Pick color for country | |
color = brewer['PRGn'][n_countries][k_country] |
This file contains 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
import torch | |
import torch.nn.functional as F | |
class Time1dConvGLU(torch.nn.Module): | |
def __init__(self, channel_inputs, channel_outputs, time_convolution_length): | |
super(Time1dConvGLU, self).__init__() | |
self.one_d_conv_1 = torch.nn.Conv1d(in_channels=channel_inputs, | |
out_channels=2 * channel_outputs, |
This file contains 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
import torch | |
import torch.nn.functional as F | |
from torch_geometric.nn import GCNConv, TAGConv | |
class SpatialGraphConv(torch.nn.Module): | |
def __init__(self, channel_inputs, channel_outputs, graph_conv_type, graph_conv_kwargs): | |
super(SpatialGraphConv, self).__init__() |
This file contains 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
import torch | |
import torch.nn.functional as F | |
from torch_geometric.data import DataLoader | |
from my_stuff import STGCN | |
from my_stuff import LondonBikeDataset | |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
london_bike_data = LondonBikeDataset() |
This file contains 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 StandardTransform(object): | |
'''Standard Image Transforms, typically instantiated and provided to the DataSet class | |
''' | |
def __init__(self, min_dim=299, to_tensor=True, square=False, | |
normalize=True, norm_mean=[0.485, 0.456, 0.406], norm_std=[0.229, 0.224, 0.225]): | |
self.transforms = [] | |
self.transforms.append(transforms.ToPILImage()) | |
self.transforms.append(transforms.Resize(min_dim)) |
This file contains 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
import torch | |
from torch import nn | |
from torchvision import models | |
class EncoderVGG(nn.Module): | |
'''Encoder of image based on the architecture of VGG-16 with batch normalization. | |
Args: | |
pretrained_params (bool, optional): If the network should be populated with pre-trained VGG parameters. | |
Defaults to True. |
This file contains 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 _encodify_(self, encoder): | |
'''Create list of modules for encoder based on the architecture in VGG template model. | |
In the encoder-decoder architecture, the unpooling operations in the decoder require pooling | |
indices from the corresponding pooling operation in the encoder. In VGG template, these indices | |
are not returned. Hence the need for this method to extent the pooling operations. | |
Args: | |
encoder : the template VGG model |
This file contains 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 forward(self, x): | |
'''Execute the encoder on the image input | |
Args: | |
x (Tensor): image tensor | |
Returns: | |
x_code (Tensor): code tensor | |
pool_indices (list): Pool indices tensors in order of the pooling modules |
This file contains 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 DecoderVGG(nn.Module): | |
'''Decoder of code based on the architecture of VGG-16 with batch normalization. | |
Args: | |
encoder: The encoder instance of `EncoderVGG` that is to be inverted into a decoder | |
''' | |
channels_in = EncoderVGG.channels_code | |
channels_out = 3 |
OlderNewer