mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-11-13 10:40:52 +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))
|
|
|
|
|