''' assert len(chain) = 2, \ "Length of input 'chain' should be 2" f1 = chain f2 = chain return f2(f1(x)) def deriv(func: Callable,ndarray], input_:ndarray, delta: float = 0.001) -> ndarray: return (func(input_ + delta) - func(input_ -delta))/(2*delta) def chain_deriv_2(chain:Chain,input_range:ndarray)->ndarray: assert len(chain) = 2,\ "This function requires 'Chain' objects of length 2" assert input_range.ndim = 1,\ "Function requires a 1 dimensional ndarray as input" f1 = chain f2 = chain f1_of_x = f1(input_range) df1dx = deriv(f1,input_range) df2du = deriv(f2,f1_of_x) return df1dx * df2du def chain_deriv_3(chain:Chain,input_range:ndarray)->ndarray: assert len(chain) = 3, \ "This function requires 'Chain' objects of length 3" f1 = chain f2 = chain f3 = chain f1_of_x = f1(input_range) f2_of_x = f2(f1_of_x) df3du = deriv(f3,f2_of_x) df2du = deriv(f2,f1_of_x) df1dx = deriv(f1,input_range) return df1dx*df2du*df3du def plot_chain(ax, chain: Chain, input_range: ndarray) -> None: ''' Plots a chain function - a function made up of multiple consecutive ndarray -> ndarray mappings - Across the input_range ax: matplotlib Subplot for plotting ''' assert input_range.ndim = 1, \ "Function requires a 1 dimensional ndarray as input_range" output_range = chain_length_2(chain, input_range) ax.plot(input_range, output_range) def plot_chain_deriv(ax, chain: Chain, input_range: ndarray) -> ndarray: ''' Uses the chain rule to plot the derivative of a function consisting of two nested functions.
#GNU OCTAVE DEEP LEARNING HOW TO#
Here's my simple RLC calulator so far, but i haven't figured out how to get lsode notation and stuff working right for the coupled linear ode's #parts R=200 L=0.5 C=100e-6 series = 0 #time constants if ((series = 0)) A = 1/(2*R*C) else A= R/(2*L) endif Wo = 1/sqrt(L*C) cp = roots (cp) end > roots (cp) ans = -341.421 -58.579Ĭode: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np from numpy import ndarray %matplotlib inline from typing import Callable from typing import List Array_Function = Callable,ndarray] Chain = List def square(x: ndarray) -> ndarray: return np.power(x, 2) def sigmoid(x:ndarray) -> ndarray: return 1/(1+np.exp(-x)) def chain_length_2(chain: Chain, x: ndarray) -> ndarray: ''' Evaluates two functions in a row, in a "Chain". Or what crash course on programming, would be the most like Octave, and preferably, be about physics/math, since at least I have that to anchor some programming around. Anyone know a good guide for Octave, and programming, for people that barely do it ? I'm trying not to get too off track from EE. I'm trying to make the ODE solver work with 2 coupled equations, to make lsode thing work. I've watched a few video's, made a script to solve for the time constants and stuff in RLC circuits.
![gnu octave deep learning gnu octave deep learning](https://i.ytimg.com/vi/HKwTcZvav9A/maxresdefault.jpg)
I find the help files need a help file to explain the common programming notations, and so have I haven't found much worked examples, to copy and try. And I've barely done programing, so I'm finding it difficult to understand the syntax, layout, structure of stuff, but is common to people that do programming all the time. I've spent a few hours fooling around with GNU octave, which is like Matlab.