Package: leoneed
Leo/needA Simple Trial on Tensor-Graph-based Network...RequirementsEnsureNumPy(NumPyon GitHub), andMatplotlib(Matplotlibon GitHub) is installed already before installingLeo/need.One of most simple ways to install them is installing it withconda:$condainstallnumpymatplotlibInstallationCurrently the latest version ofLeo/needcan be installed withpipas following:$pipinstallleoneed--upgradeorfrom sourcelike other packages.ImportationTo accessLeo/needand its functions import it in your Python code like this:>>>importleoneedaslnどうだっていい存在じゃない、簡単に愛は終わらないよ。Componentsneedle: Nodes in Tensor-Graph>>>mulmat=ln.needle.Mul_Matrix((3,4))>>>mulmat.tensormatrix([[1.40483957,0.22112104,-0.14532731,0.12319917],[0.60602697,2.42277001,-1.91660854,-2.42252709],[0.64629422,0.20150064,-0.15671318,0.77204576]])stella: Instances of Loss FunctionsIt Returns the Value and the Gradient of the Specified Loss Function.>>>simploss=ln.stella.Loss_Simple(3)# Loss Function: (y_pred - y_true)^2 / 2>>>simploss([1,3,4],[5,7,1])(matrix([[8.,8.,4.5]]),matrix([[-4,-4,3]]))stage: Models' ContainersBATCH_SIZE=128NUM_EPOCHES=39MINI_BATCH=5ae=ln.stage.Auto_Encoder(3,2)print("W_Encoder(pre-training):",ae[0].tensor,sep="\n")print("b_Encoder(pre-training):",ae[1].tensor,sep="\n")print("W_Decoder(pre-training):",ae[3].tensor,sep="\n")print("b_Decoder(pre-training):",ae[4].tensor,sep="\n")randdata=np.random.randn(BATCH_SIZE)randdata/=np.abs(randdata).max()*1.28traindata=np.zeros((BATCH_SIZE,3))# Constructing a Dataset Filled with Sample Vectors like (+a, 0, -a) Manually.traindata[:,0]+=randdatatraindata[:,2]-=randdataae_history=[]foridx_epochinrange(NUM_EPOCHES):forkinrange(BATCH_SIZE):ae,ae_loss=ae.fit_sample(traindata[k:(k+1),:],traindata[k:(k+1),:])ae_history.append(ae_loss)print("W_Encoder(pst-training):",ae[0].tensor,sep="\n")print("b_Encoder(pst-training):",ae[1].tensor,sep="\n")print("W_Decoder(pst-training):",ae[3].tensor,sep="\n")print("b_Decoder(pst-training):",ae[4].tensor,sep="\n")withplt.rc_context({}):plt.plot(ae_history,label="Loss")plt.legend()plt.xlabel("Iterations")plt.title("Gradient Descend, on the same Batch of%dSamples."%BATCH_SIZE)plt.savefig("./gradloss-ae.jpeg")plt.show()Output:W_Encoder(pre-training):[[1.404839570.22112104][-0.145327310.12319917][0.606026972.42277001]]b_Encoder(pre-training):[[0.0.]]W_Decoder(pre-training):[[-1.91660854-2.422527090.64629422][0.20150064-0.156713180.77204576]]b_Decoder(pre-training):[[0.0.0.]]W_Encoder(pst-training):[[0.877220830.77930038][-0.145327310.12319917][1.133645711.86459068]]b_Encoder(pst-training):[[-0.004980580.00632017]]W_Decoder(pst-training):[[-1.88554672-2.211713360.71931055][-0.564036060.555493260.85221518]]b_Decoder(pst-training):[[0.00564453-0.01603693-0.01378995]]ChangelogVersion0.0.3Finished Implementation of Gradient after Matrix-Multiplication;Added API of Generating AE (Auto-Encoder):.stage.Auto_Encoder(numvisible, numhidden, w1=None, w2=None);Version0.0.2Added sub-moduleneedle(Nodes of Tensor-Graph),stella(Loss Functions), andstage;References[^extra-1]: Harry-P (針原 翼),Issenkou, 2017,av17632876;Extra息吹く炎、君の鼓動の中。Flames Breathing, in your Heartbeat.
火炎般的氣息，綻放於你跳動的心臟。---- Harry-P in "Issenkou"[^extra-1]