Skip to content

Instantly share code, notes, and snippets.

[2022-11-11 17:48:02,104] {train.py:88} INFO - Step: 100/1000000 | Loss: 1.25540
0%| | 199/1000000 [02:12<193:03:53, 1.44it/s][2022-11-11 17:49:11,880] {train.py:88} INFO - Step: 200/1000000 | Loss: 0.32713
0%| | 299/1000000 [03:24<212:03:41, 1.31it/s][2022-11-11 17:50:23,737] {train.py:88} INFO - Step: 300/1000000 | Loss: 0.31745
0%| | 399/1000000 [04:36<195:45:43, 1.42it/s][2022-11-11 17:51:35,544] {train.py:88} INFO - Step: 400/1000000 | Loss: 0.34129
0%|
# do the k means
for i in range(10): cs = (((torch.argmin((xs[None] - cs[:, None]).pow(2).sum(-1).sqrt(), dim=0) == torch.arange(n_clusters)[None].t()).float() @ xs.float()) / (torch.argmin((xs[None] - cs[:, None]).pow(2).sum(-1).sqrt(), dim=0) == torch.arange(n_clusters)[None].t()).sum(-1).t()[:,None]).nan_to_num(0.)
@pvwoods
pvwoods / .emacs
Created July 20, 2018 04:56
My emacs file
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
@pvwoods
pvwoods / r53_set.sh
Last active May 22, 2018 19:08
DynDNS replacement
#!/bin/sh
AWS_ROUTE53_ZONEID="REDACTED"
HOSTNAME="blah.blah.io"
TTL="600"
IP=`curl http://v4.ifconfig.co/ 2>/dev/null`
aws route53 change-resource-record-sets --hosted-zone-id $AWS_ROUTE53_ZONEID --change-batch "{ \"Changes\": [ { \"Action\": \"UPSERT\", \"ResourceRecordSet\": { \"Name\": \"$HOSTNAME\", \"Type\": \"A\", \"TTL\": $TTL, \"ResourceRecords\": [ { \"Value\": \"$IP\" } ] } } ] }"
echo "Updated the DNS Zone to $IP"
@pvwoods
pvwoods / grate.nc
Created August 20, 2017 21:36
grate CNC gCode
%
(1001)
(T2 D=7.938 CR=0 - ZMIN=-20 - flat end mill)
G90 G94
G17
G21
(2D Contour2)
M9
T2 M6

Keybase proof

I hereby claim:

  • I am pvwoods on github.
  • I am pwoods (https://keybase.io/pwoods) on keybase.
  • I have a public key ASBSzldEmU3P7lGQOynwFrlcWaLiTv3Hk2ntFKiF3-Gq5go

To claim this, I am signing this object:

@pvwoods
pvwoods / auto.js
Created February 5, 2017 23:17
websdr challenge auto completer
var a = setInterval(function() {
if(document.forms['chatform'].elements['sum'].value == "") {
document.forms['chatform'].elements['sum'].value = eval(document.getElementById("chatboxchallenge").innerHTML);
}
}, 1000)
def longest_increasing_subsequence(nums):
stacks = []
for num in nums:
for i in range(len(stacks)):
if num < stacks[i][-1]:
stacks[i].append(num)
break
else:
stacks.append([num])
def get_ranges(keys, shards):
key_index = 0
ranges = [keys[0][0], keys[0][0]]
for shard_lo, shard_hi in shards:
while key_index < len(keys) * 2:
key_major_index = key_index / 2
key_minor_index = key_index % 2
if keys[key_major_index][key_minor_index] <= shard_hi:
ranges[-1] = keys[key_major_index][key_minor_index]
key_index += 1
# convert html to KV tuples
meta = [x.split(": ") for x in string.findAll(text=True)]
for a in b:
if len(a) == 2:
result.append(a)
elif len(a) == 1 and result[-1][0] == '':
result[-1][1] = a[0]