Skip to content

Instantly share code, notes, and snippets.

@cflamant
cflamant / embedmp4.txt
Last active December 20, 2020 18:27
Hugo Looping Autoplaying MP4
<!-- For use within a .md file -->
{{< rawhtml >}}
<video autoplay loop muted playsinline style="max-width:100%">
<source src="images/earth_moon_neural_network_solution_bundle_training.mp4" type="video/mp4">
<img src="images/earth_moon_neural_network_solution_bundle_training.png">
</video>
{{< /rawhtml >}}
@cflamant
cflamant / pytorch_trainingloop.py
Created December 11, 2019 07:51
PyTorch Training loop example using tqdm to monitor progress (won't run by itself, needs to be in a class)
## Example training loop from within a class which contains
## a PyTorch nn.Module() under the variable self.net()
optimizer = optim.SGD(self.net.parameters(), lr=0.001)
train_losses = []
with tqdm.trange(num_batch) as batches:
for b in batches:
x = self.getdata()
# Call network for forward pass
losses = self.net(x)
@cflamant
cflamant / dynamic_subclass.py
Last active December 12, 2019 00:42
Code to demonstrate how to create subclasses dynamically when the superclass is not known before execution
"""
Code to demonstrate dynamically creating subclasses for a
superclass that is not known before execution.
General idea: you want to make a subclass that is a baby animal,
but you don't know whether it will be a Human or Sheep (or possibly
another animal from a different module) until the code is run.
By creating the subclass dynamically (using the "type" function),
you can avoid writing a separate subclass for each superclass possibility.
@cflamant
cflamant / keybase.md
Created September 10, 2019 21:04
Keybase

Keybase proof

I hereby claim:

  • I am cflamant on github.
  • I am cflamant (https://keybase.io/cflamant) on keybase.
  • I have a public key ASB9Tyc25osLdZyP8GTH4CdMt8Qz4kF3xJQCqH3sDfkwkwo

To claim this, I am signing this object: