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
// | |
// Created by duane on 10/2/20. | |
// | |
#include <torch/torch.h> | |
int main(int arg, char *argv[]){ | |
auto x = torch::randn(3, torch::requires_grad()); | |
auto z = torch::randn(3, torch::requires_grad()); |
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
cmake_minimum_required(VERSION 3.5) | |
project(ros2_cpp_pkg) | |
# Default to C99 | |
if(NOT CMAKE_C_STANDARD) | |
set(CMAKE_C_STANDARD 99) | |
endif() | |
# Default to C++14 | |
if(NOT CMAKE_CXX_STANDARD) |
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
from vpython import sphere, vector, rate, color, arrow, canvas, cross, triangle, vertex | |
from math import sqrt | |
G = 6.67e-11 # N kg^-2 m^2 | |
au = 1.495978707e11 | |
day = 60 * 60 * 24 | |
year = day * 365.25 | |
earth_mass = 5.972e24 # kg |
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 glfw | |
from OpenGL.GL import * | |
from OpenGL.GL.shaders import compileProgram, compileShader | |
import numpy as np | |
import pyrr | |
def init_window(width, height, title="My OpenGL window"): | |
# initializing glfw library | |
if not glfw.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 | |
from torch import tensor | |
from torch.distributions.multivariate_normal import MultivariateNormal | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Ellipse | |
import matplotlib.patches as mpatches | |
from math import acos, degrees | |
from matplotlib.pyplot import cm | |
""" |
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.distributions.normal import Normal | |
from torch.distributions.multivariate_normal import MultivariateNormal | |
""" | |
Example of computing c batched Normal and Multivariate distributions from data | |
and sampling batches from them | |
""" |
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.distributions.normal import Normal | |
import matplotlib.pyplot as plt | |
""" | |
EM algo demo, in pytorch | |
""" | |
n = 40 # must be even number |
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.distributions.normal import Normal | |
import matplotlib.pyplot as plt | |
""" | |
Using Bayes to estimate the relative probability of 2 Hypotheses given the value of a single data point | |
Both hypothesis given equal prior probability of being correct | |
""" |
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.distributions.normal import Normal | |
from torch.distributions.multivariate_normal import MultivariateNormal | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import Axes3D | |
d = Normal(0.0, 1.0) | |
x = torch.linspace(-4, 4.0, 50) | |
y = torch.exp(d.log_prob(x)) | |
plt.plot(x, y) |
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 multiprocessing as mp | |
import os | |
import numpy as np | |
import multiprocessing.spawn | |
def info(title): | |
print(title) | |
print('module name:', __name__) | |
print('parent process:', os.getppid()) | |
print('process id:', os.getpid()) |