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
# Since convolution takes the most time, only do it on images with | |
# mask = 1. Note that masks.data.nonzero() is of size (N, 1). | |
# As a result, when expanding to 4 dims, we need to unsqueeze it twice. | |
selected_idx = Variable(masks.data.nonzero().unsqueeze(2).unsqueeze(3).repeat( | |
1, images.size(1), images.size(2), images.size(3))) | |
selected_images = torch.gather(images, 0, selected_idx) | |
# Get image features from CNN and linear layer rnn_emb. | |
some_im_feats = self.rnn_emb(self.cnn(selected_images).squeeze()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
bool ReadCSVToDatum(const string& filename, Datum* datum) { | |
// read in the CSV file into a vector | |
fstream file(filename.c_str(), ios::in); | |
vector<vector<int> > label; | |
std::string line; | |
while (std::getline(file, line)) { | |
// replace commas with spaces | |
for (int i = 0; i < line.length(); i++) { | |
if (line[i] == ',') | |
line[i] = ' '; |
NewerOlder