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.
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 BFS(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| # convolutional kernel to connect with neighbors on the grid | |
| self.step = nn.Conv2d(1, 1, kernel_size=3, padding=1, bias=False) | |
| self.step.weight.data = 0.3 * torch.tensor([[1, 1, 1], | |
| [1, 2, 1], | |
| [1, 1, 1]]).view(1,1,3,3) | |
| self.steps = 4 |
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
| # prior - likelihood conflict | |
| library(rethinking) | |
| yobs <- 0 | |
| mtt <- ulam( | |
| alist( | |
| y ~ dstudent(2,mu,1), | |
| mu ~ dstudent(2,10,1) |
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
| "Two independent linear maps using grouped Conv1d" | |
| import torch | |
| import torch.nn as nn | |
| class DualLinearSerial(nn.Module): | |
| def __init__(self, in_channels, out_channels, bias=True): | |
| super().__init__() | |
| self.left = nn.Linear(in_channels // 2, out_channels // 2, bias=bias) | |
| self.right = nn.Linear(in_channels // 2, out_channels // 2, bias=bias) |
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
| diff --git a/cuda/practicals/tree-ex1/findneighbors.hpp b/cuda/practicals/tree-ex1/findneighbors.hpp | |
| index 7ba7329..412e6cd 100644 | |
| --- a/cuda/practicals/tree-ex1/findneighbors.hpp | |
| +++ b/cuda/practicals/tree-ex1/findneighbors.hpp | |
| @@ -16,7 +16,7 @@ namespace cstone | |
| //! @brief generic depth-first traversal of an octree that works on CPU and GPU with customizable descent criteria | |
| template<class C, class A> | |
| -void depthFirstTraversal(const TreeNodeIndex* childOffsets, C&& continuationCriterion, A&& endpointAction) | |
| +__host__ __device__ void depthFirstTraversal(const TreeNodeIndex* childOffsets, C&& continuationCriterion, A&& endpointAction) |
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
| import torch | |
| import torch.nn as nn | |
| import math | |
| input_dim = 80 | |
| head_dim = 64 | |
| heads = 12 | |
| p_drop = 0.1 | |
| layers = 6 | |
| context = 128 |
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
| import argparse | |
| from pathlib import Path | |
| from hashlib import sha1 | |
| import math | |
| import torch | |
| parser = argparse.ArgumentParser(description='compute nll/bpc/bpb on a text dataset') | |
| parser.add_argument('--device', type=str, default='cuda:0') | |
| parser.add_argument('ckpt_path') |
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
| import numpy as np | |
| def rgb_to_hue(image): | |
| """Compute hue value from BGR image. | |
| Uses Hue definition from https://mattlockyer.github.io/iat455/documents/rgb-hsv.pdf | |
| """ | |
| image = image / 255 | |
| m_max = np.max(image, axis=-1) # (W,H,C) -> (W,H) | |
| m_min = np.min(image, axis=-1) # (W,H,C) -> (W,H) |