Learning notes from reading Chainer Tutorial
Core Functionalities
Function Functions that operate Variable
Parameters can be used to visualize the learned layer
Variable In short, a wrapper for arrays such as features?
import numpy as np
import chainer
a = np.random.rand(100, 50) * 100
→array([[ 73.79944963, 20.34729163, 17.8695034 , ..., 95.2588098 ,
80.70607058, 72.77696887],
[ 63.61317915, 52.34471719, 6.63279207, ..., 23.84326461,
59.21347284, 99.79442349],
[ 14.70947019, 73.28647468, 57.40101832, ..., 0.13991004,
0.69580569, 35.80244434],
...,
[ 99.22098719, 50.55196297, 18.42562383, ..., 33.23917582,
28.41971731, 95.31789821],
[ 57.03728122, 37.14647991, 45.64473654, ..., 50.12747623,
61.67733488, 33.88739351],
[ 46.90448489, 89.0190541 , 58.7650971 , ..., 71.94147691,
88.81614863, 90.15044102]])
b = chainer.Variable(a)
→<chainer.variable.Variable object at 0x10b335e50>
#Get an array
b.data
→→array([[ 73.79944963, 20.34729163, 17.8695034 , ..., 95.2588098 ,
80.70607058, 72.77696887],
[ 63.61317915, 52.34471719, 6.63279207, ..., 23.84326461,
59.21347284, 99.79442349],
[ 14.70947019, 73.28647468, 57.40101832, ..., 0.13991004,
0.69580569, 35.80244434],
...,
[ 99.22098719, 50.55196297, 18.42562383, ..., 33.23917582,
28.41971731, 95.31789821],
[ 57.03728122, 37.14647991, 45.64473654, ..., 50.12747623,
61.67733488, 33.88739351],
[ 46.90448489, 89.0190541 , 58.7650971 , ..., 71.94147691,
88.81614863, 90.15044102]])
#You can get the type of value etc.
b.label
→'(100, 50), float64'
#Get the full number of values
b.__len__()
→5000
FunctionSet
Function wrapper class. Used when sending an entire Function to the GPU or passing parameters and gradients to the Optimizer class.
We will update it from time to time.
Recommended Posts