fix sample processor

This commit is contained in:
iperov 2021-10-09 13:56:53 +04:00
parent 3aa2b56eda
commit f8469fe4d7
3 changed files with 36 additions and 127 deletions

View file

@ -1,12 +1,14 @@
import numpy as np
def random_normal( size=(1,), trunc_val = 2.5 ):
def random_normal( size=(1,), trunc_val = 2.5, rnd_state=None ):
if rnd_state is None:
rnd_state = np.random
len = np.array(size).prod()
result = np.empty ( (len,) , dtype=np.float32)
for i in range (len):
while True:
x = np.random.normal()
x = rnd_state.normal()
if x >= -trunc_val and x <= trunc_val:
break
result[i] = (x / trunc_val)