neuropercolation/evaluation/2Layer Sonic.py

72 lines
1.3 KiB
Python
Raw Normal View History

2023-12-10 21:47:15 +00:00
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 30 14:25:12 2022
@author: timof
"""
import sys
import os
import json
# from plot import qtplot
from scipy.io import wavfile
import math as m
import numpy as np
vect = np.vectorize
@vect
def log2(x):
try:
return m.log2(x)
except ValueError:
if x==0:
return float(0)
else:
raise
def new_folder(path):
if not os.path.exists(path):
os.makedirs(path)
return path
phase = np.vectorize(lambda x,y: (m.atan2(y,x)+m.pi)%(2*m.pi)-m.pi)
diff = np.vectorize(lambda x,y: (y-x+m.pi)%(2*m.pi)-m.pi)
H2 = lambda x: -x*m.log2(x)-(1-x)*m.log2(1-x)
path = '/cloud/Public/_data/neuropercolation/2lay/steps=500000_rising/'
suffix = ''
chi = chr(967)
vareps = chr(949)
vals = [[],[]]
runsteps = 1000100
eps_space = np.linspace(0.005, 0.5, 100)
eps_space = eps_space[1::2]
dims = [121]#+[16,49]
mode='density'
ma=[]
s=[]
k=[]
mk=[]
lastkurt=None
for dim in dims:
dimpath = new_folder(path + f'dim={dim:03d}/')
for epsilon in [0.000]:
with open(dimpath+f"eps={round(epsilon,3):.3f}_activation.txt", 'r', encoding='utf-8') as f:
activation = np.array(json.load(f)[::-1])
# activation = list(zip(*activation))
wavfile.write(dimpath+f"eps={round(epsilon,3):.3f}_activation_48k.wav_rev",48000,activation)