Skip to content

Instantly share code, notes, and snippets.

Nur Lan 0xnurl

Block or report user

Report or block 0xnurl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@0xnurl
0xnurl / Dockerfile
Created Mar 14, 2018
Compile OpenFST Python Extension for Python 3
View Dockerfile
FROM ubuntu:16.04
# Use bash (Ubuntu default is dash)
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Ubuntu packages
RUN apt-get update && apt-get install -y ssh gcc=4:5.3.1-1ubuntu1 g++=4:5.3.1-1ubuntu1 make vim zlib1g-dev libbz2-dev libssl-dev python-dev man libreadline-dev build-essential libreadline-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev python3 python3-dev
# Install Python 3.6 from source for optimizations
RUN cd /tmp && wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && tar xzvf Python-3.6.0.tgz && cd Python-3.6.0 && ./configure && make && make install && cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
@0xnurl
0xnurl / non_null_accuracy.py
Created Apr 24, 2017
Keras metric for non-null targets accuracy, mainly for Named Entity Recognition models
View non_null_accuracy.py
def non_null_label_accuracy(y_true, y_pred):
"""Calculate accuracy excluding targets that are the null label (at index 0).
Useful when the null target is over-represented in the data, like in Named Entity Recognition tasks.
typical y shape: (batch_size, sentence_length, num_labels)
"""
y_true_argmax = K.argmax(y_true, -1) # ==> (batch_size, sentence_length, 1)
y_pred_argmax = K.argmax(y_pred, -1) # ==> (batch_size, sentence_length, 1)
@0xnurl
0xnurl / openfst_python_on_macos.md
Last active Sep 19, 2019
Installing OpenFST Native Python Extension on MacOS
View openfst_python_on_macos.md

Installing OpenFst Native Python Extension on MacOS

Starting from version 1.5, OpenFst has offered a native Python module, making the use of external wrappers like PyFst unnecessary. This has been greatly helpful since PyFst doesn't support Python 3.

1. Install OpenFst

You can’t perform that action at this time.