Skip to content

Instantly share code, notes, and snippets.

@hopezh
hopezh / quickstart.py
Created July 2, 2023 13:24
PyTorch QuickStart Example Code
import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision.transforms import ToTensor
print("PyTorch version:", torch.__version__)
# ------------------------------------------------------------------------------
# download training data
@hopezh
hopezh / index.jsx
Created June 3, 2023 16:02
react-three/fiber scene
import "./style.css";
import ReactDOM from "react-dom/client";
// import * as THREE from "three";
import { Canvas } from "@react-three/fiber";
import Episode from "./Episode.js";
import * as THREE from "three";
import React from 'react'
import Plot from 'react-plotly.js'
const root = ReactDOM.createRoot(document.querySelector("#root"));
@hopezh
hopezh / plotly_3d_axis_range_issue.ipynb
Created January 27, 2022 08:14
ploty 3d chart, x axis range and nticks not shown as specified
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hopezh
hopezh / settings.json
Created January 25, 2022 15:54
settings.json for vscode insider that produces a warning
{
"editor.fontFamily": "JetBrains Mono, Consolas, 'Courier New', monospace",
"editor.formatOnSave": true,
"editor.rulers": [80],
"editor.scrollBeyondLastLine": false,
"git.autofetch": true,
"prettier.useTabs": true,
"prettier.tabWidth": 4,
@hopezh
hopezh / test.ipynb
Created February 7, 2021 13:36
test notebook gist
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hopezh
hopezh / test_tqdm.py
Created February 7, 2021 13:29
test python script for tqdm
from tqdm import tqdm
import torch
import time
from datetime import timedelta
@torch.jit.script
def foo():
x = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32)
y = torch.ones((1024 * 12, 1024 * 12), dtype=torch.float32)
z = x + y