net.add_edge(Edge(start='a', end='b', phase=phi1, attenuation=amp1, delay=1)) net.add_edge(Edge(start='b', end='c', phase=phi2, attenuation=amp2, delay=2)) net.add_edge(Edge(start='b', end='d', phase=3, attenuation=0.4, delay=3)) net.add_input(name='a', amplitude=1.0, phase=0) net.visualize(path='./visualizations/symbolicfeedforward', format='svg') net.evaluate(use_shared_default=False, feed_dict=None) # print('paths leading to c:', net.get_paths('c')) # print('paths leading to d:', net.get_paths('d')) print('waves arriving at c:', net.get_result('c')) print('waves arriving at d:', net.get_result('d')) net.get_html_result(['c', 'd'], path='./visualizations/symbolicfeedforward.html') # Evaluation without feed dictionary, using the default value of each SymNum waves = [ tuple([ w.eval(feed_dict=None, use_shared_default=False) if hasattr(w, 'eval') else w for w in inner ]) for inner in net.get_result('c') ] print('Waves arriving at c:', waves, '\n') print(net.get_eval_result(name='c', feed_dict=None, use_shared_default=False)) # Evaluation without feed dictionary, with global defaults waves = [ tuple([ w.eval(feed_dict=None, use_shared_default=True) if hasattr(w, 'eval') else w for w in inner
# Add nodes net.add_node(name='a') net.add_node(name='b') net.add_node(name='c') net.add_node(name='d') # Add edges net.add_edge(Edge(start='a', end='b', phase=1, attenuation=0.8, delay=1)) net.add_edge(Edge(start='b', end='c', phase=2, attenuation=0.6, delay=2)) net.add_edge(Edge(start='b', end='d', phase=3, attenuation=0.4, delay=3)) # Add input net.add_input(name='a', amplitude=1.0, phase=0) # Visualize the network net.visualize(path='./visualizations/feedforward', format='svg') # Evaluate the network net.evaluate(amplitude_cutoff=1e-3) # Compute output and show results print('paths leading to c:', net.get_paths('c')) print('paths leading to d:', net.get_paths('d')) print('waves arriving at c:', net.get_result('c')) print('waves arriving at d:', net.get_result('d')) print('latex string for waves arriving at c:', net.get_latex_result('c')) # render output in a html file net.get_html_result(['c', 'd'], precision=2, path='./visualizations/feedforward.html')
net.add_node(name='c') net.add_edge(Edge(start='a', end='b', phase=2, attenuation=amp1, delay=1)) net.add_edge(Edge(start='b', end='c', phase=1, attenuation=amp2, delay=2)) net.add_edge( Edge(start='c', end='a', phase=phi3, attenuation=0.5 * amp3, delay=3)) net.add_input('a') net.add_input('b') net.evaluate(amplitude_cutoff=0.001) net.visualize(path='./visualizations/docdemo', format='png') net.visualize(path='./visualizations/docdemo', format='svg') print(net.get_result('b')) print(net.get_latex_result('b', linebreak_limit=1)) net.get_html_result(['c', 'b'], path='./visualizations/docdemo_latex.html') ### Create a testbench with a feed dictionary tb = Testbench(network=net, timestep=0.05, feed_dict={ 'v1': 0.8, 'v2': 0.8, 'v3': 0.9, 'v4': 3 }) x_in_a = np.sin(np.linspace(0, 2 * np.pi, 400)) # create the input signal (Dimensino N) t_in = np.linspace(0, 20, num=401) # create the input time vector (Dimension N+1) tb.add_input_sequence(node_name='a', x=x_in_a, t=t_in)