Skip to content

Instantly share code, notes, and snippets.

View taiya's full-sized avatar

Andrea Tagliasacchi taiya

View GitHub Profile
import types
model = types.SimpleNamespace(
config = config,
grid = grid,
)
class AttrDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
mydict = {
'a': 'foo',
'b': 'bar',
}
mydict = AttrDict(mydict)
def get_dataset_mock(num_examples=1, num_classes=40):
output_types = {'points': tf.float32, 'label': tf.int64}
output_shapes = {'points': (2048, 3), 'label': (1,)}
def generator():
for i in range(num_examples):
yield {
'points':
tf.random.uniform(
output_shapes['points'],
# --- specify target with `make run TARGET=mnist.py`
TARGET=mnist.py
run:
ml_python $(TARGET)
# --- passing parameters `# make helloworld_pars MYVAR="something"`
MYVAR = "hello"
helloworld_pars:
@echo "foo" $(MYVAR)
# --- save a numpy matrix as an OBJ file
M = np.random.randn(100, 3)
np.savetxt('out.obj', M, fmt=['%d', '%d', '%d'])
@taiya
taiya / TFDS
Last active September 14, 2021 16:06
# --- Performance considerations
# https://www.tensorflow.org/datasets/performances
# --- For more advanced transformation piplines
# https://www.tensorflow.org/tfx/tutorials/transform/simple
# --- Pre-processing dataset (read this CAREFULLY)
# https://www.tensorflow.org/api_docs/python/tf/data/Dataset#map
# https://www.tensorflow.org/guide/data_performance#vectorizing_mapping
alias ll="ls -l"
export PATH="$PATH:." #< current folder always in bin
export PS1="\[\e[33m\]\w: \[\e[0m\]"
export CLICOLOR=1 #< enables colors
export LSCOLORS=ExFxCxDxBxegedabagacad #< specifies colors
export TZ="Canada/Pacific"
export PROMPT_DIRTRIM=2 #< trims long paths
@taiya
taiya / jekyll
Last active July 17, 2021 18:11
~: docker run -v "$HOME/jalpc:/srv/jekyll" -p 4000:4000 -it jekyll/jekyll:builder jekyll serve
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
Bundler::PermissionError: There was an error while trying to write to `/usr/gem/cache`. It is likely that you need to grant write permissions for that path.
An error occurred while installing concurrent-ruby (1.1.9), and Bundler cannot continue.
Make sure that `gem install concurrent-ruby -v '1.1.9' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
github-pages was resolved to 215, which depends on
@taiya
taiya / DefaultKeyBinding.dict
Last active July 22, 2018 18:55
Changes shortcuts in OSX to have similar behavior to Linux
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
Based on: https://gist.github.com/trusktr/1e5e516df4e8032cbc3d
System file: /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict
Official info: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
Complex example: https://github.com/ttscoff/KeyBindings/blob/master/DefaultKeyBinding.dict
NOTE:
To use Control instead of Command, either swap Control and
Command in Apple->System Preferences->Keyboard->Modifier Keys...