mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
13 lines
180 B
Python
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))
|
|
|
|
|