mosesdecoder/contrib/promix/util.py
2013-02-21 17:59:53 +00:00

13 lines
180 B
Python

#!/usr/bin/python
import numpy as np
floor = np.exp(-100)
def safelog(x):
"""Wraps np.log to give it a floor"""
#return np.log(x)
return np.log(np.clip(x,floor,np.inf))