Skip to content

Instantly share code, notes, and snippets.

View JEM-Mosig's full-sized avatar

Johannes E. M. Mosig JEM-Mosig

View GitHub Profile
@JEM-Mosig
JEM-Mosig / CodeCompatibilityData.wl
Last active October 21, 2017 09:48
Simple code to estimate the compatibility of a Wolfram Language script
(* author: https://github.com/JEM-Mosig *)
(* example: CodeCompatibilityData["test.wl"] *)
ClearAll[CodeCompatibilityData];
CodeCompatibilityData[wlFile_String] := Module[{str, symbols},
(* read the whole file as a string *)
str = ReadString[wlFile];
(* delete all strings in the code *)
str = StringDelete[str,"\""~~Shortest[___]~~"\""];
(* delete all comments in the code (unsafe!) *)

Keybase proof

I hereby claim:

  • I am jem-mosig on github.
  • I am jem_mosig (https://keybase.io/jem_mosig) on keybase.
  • I have a public key ASAnLueCCtiZfcA2CwDEuR0Ix98vVWVD9zKZcn5zTBtEHwo

To claim this, I am signing this object:

@JEM-Mosig
JEM-Mosig / blog-mackay_gaussian_2006.md
Last active April 2, 2019 10:26
blog-mackay_gaussian_2006

Wolframscripts that generate figures in my blog post

The scripts in this gist generate the animated figures in my blog post mackay_gaussian_2006. You need Wolfram Mathematica 11 or higher to run these scripts. For example,

wolframscript <name>.wls

will generate the figure .png in the current directory, where `` is the name of the script.

@JEM-Mosig
JEM-Mosig / snickers.wl
Last active April 8, 2019 12:55
This Wolfram Language (Mathematica) code generates an interactive data-exploration tool for our Snickers experiment.
With[{
data = {<|"ID"->1,"Experimenter"->"Nellissa","Outcome"->"DE\[NotEqual]VN","Countries"->{"DE","VN"},"Same"->False,"Comment"->"One is sweet, the other caramelly"|>,<|"ID"->2,"Experimenter"->"Nellissa","Outcome"->"GB\[NotEqual]VN","Countries"->{"GB","VN"},"Same"->False,"Comment"->"One tasts like coffee and sweeter"|>,<|"ID"->3,"Experimenter"->"Nellissa","Outcome"->"DE\[Equal]VN","Countries"->{"DE","VN"},"Same"->True,"Comment"->""|>,<|"ID"->4,"Experimenter"->"Nellissa","Outcome"->"VN\[NotEqual]VN","Countries"->{"VN","VN"},"Same"->False,"Comment"->"One is sweeter"|>,<|"ID"->5,"Experimenter"->"Nellissa","Outcome"->"VN\[Equal]VN","Countries"->{"VN","VN"},"Same"->True,"Comment"->"Terrible"|>,<|"ID"->6,"Experimenter"->"Nellissa","Outcome"->"DE\[Equal]GB","Countries"->{"DE","GB"},"Same"->True,"Comment"->"(?) Tasts the same, peanutty and caramelly"|>,<|"ID"->7,"Experimenter"->"Nellissa","Outcome"->"GB\[NotEqual]VN","Countries"->{"GB","VN"},"Same"->False,"Comment"->"One is too sweet"|>,<|"ID"->8,"Experimenter"
@JEM-Mosig
JEM-Mosig / simple_som.py
Created May 17, 2019 08:25
Simple self-organizing-map code (not optimized for performance)
import numpy as np
class SelfOrganizingMap(object):
def __init__(self, map_dims, input_dim):
self.map_dims = map_dims
self.input_dim = input_dim
#!/bin/bash
# Based on: https://stackoverflow.com/a/25180186
function try()
{
[[ $- = *e* ]]; SAVED_OPT_E=$?
set +e
}
function throw()
@JEM-Mosig
JEM-Mosig / gist:9d302dbaf8933d3cd5e93e9e0945cf45
Created August 14, 2020 11:33
Error log rasa train core
(rasa-master) jem-mosig:trivia/ (testing✗) $ rasa train core [13:31:03]
2020-08-14 13:31:16 ERROR pykwalify.core - validation.invalid
2020-08-14 13:31:16 ERROR pykwalify.core - --- All found errors ---
2020-08-14 13:31:16 ERROR pykwalify.core - ["Cannot find required key 'intent'. Path: '/rules/2/steps/2'", "Key 'form' was not defined. Path: '/rules/2/steps/2'", "Key 'form' was not defined. Path: '/rules/2/steps/2'", "Key 'form' was not defined. Path: '/rules/2/steps/2'", "Key 'form' was not defined. Path: '/rules/2/steps/2'", "Cannot find required key 'intent'. Path: '/rules/3/steps/2'", "Key 'form' was not defined. Path: '/rules/3/steps/2'", "Key 'form' was not defined. Path: '/rules/3/steps/2'", "Key 'form' was not defined. Path: '/rules/3/steps/2'", "Key 'form' was not defined. Path: '/rules/3/steps/2'", "Key 'form' was not defined. Path: '/rules/4/condition/0'", "Key 'form' was not defined. Path: '/rules/4/condition/0'", "Cannot find required key 'intent'. Path: '/rule
@JEM-Mosig
JEM-Mosig / pad_right_for_tensorflow.py
Created April 29, 2021 09:44
pad_right for tensorflow
import tensorflow as tf
from tensorflow import Tensor, TensorShape
from typing import Union
def pad_right(
x: Tensor, target_shape: TensorShape, value: Union[int, float] = 0
) -> Tensor:
"""Creates a tensor of shape `target_shape` by padding it with `value` on the right.
@JEM-Mosig
JEM-Mosig / rasa_diagnostic_data_access.md
Created January 21, 2021 13:16
Rasa diagnostic data access

You can access diagnostic data for DIET like this (please define the YOUR_RASA_MODEL_DIRECTORY and YOUR_RASA_MODEL_NAME constants):

from rasa.cli.utils import get_validated_path
from rasa.model import get_model, get_model_subdirectories
from rasa.nlu.model import Interpreter
from rasa.shared.nlu.training_data.message import Message
from rasa.shared.nlu.constants import TEXT
from rasa.shared.constants import DIAGNOSTIC_DATA
import pathlib