Changeset 40325 for trunk/Ohana/src/opihi/cmd.data/test/nnet.sh
- Timestamp:
- Jan 27, 2018, 1:09:32 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/test/nnet.sh (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/test/nnet.sh
r40323 r40325 161 161 nnet apply t1 x0 x1 y0 y1 162 162 163 nnet create tn 2 2 164 nnet train tn x0 x1 y0 y1 -Nmini $Nmini -Nepoch $Nepoch -eta $eta 163 # -large-weight-initializer : revert to original implementation 164 nnet create tn 2 2 165 # nnet create tn 2 2 -large-weight-initializer 166 167 # -quadratic-cost : revert to original implementation 168 nnet train tn x0 x1 y0 y1 -Nmini $Nmini -Nepoch $Nepoch -eta $eta -lambda 0.0 -quadratic-cost 169 # nnet train tn x0 x1 y0 y1 -Nmini $Nmini -Nepoch $Nepoch -eta $eta -lambda 0.0 170 # nnet train tn x0 x1 y0 y1 -Nmini $Nmini -Nepoch $Nepoch -eta $eta -lambda 2.0 165 171 166 172 nnet apply tn x0 x1 Y0 Y1 … … 169 175 set dy1 = y1 - Y1 170 176 171 vstat -qdy0177 vstat dy0 172 178 $yp = $MAX 173 179 $ym = $MIN 174 180 175 vstat -qdy1181 vstat dy1 176 182 $yp = max ($MAX , $yp) 177 183 $ym = min ($MIN , $ym) … … 181 187 end 182 188 189 macro test.bilevel 190 if ($0 != 4) 191 echo "USAGE: test.bilevel (Nmini) (Nepoch) (eta)" 192 break 193 end 194 195 local Nmini Nepoch eta 196 $Nmini = $1 197 $Nepoch = $2 198 $eta = $3 199 200 # create a nnet with just 2 inputs and 2 outputs 201 nnet create t1 3 4 3 202 203 # biases: 204 vlist v1 -0.2 0.0 0.2 0.4 205 vlist v2 -0.5 0.0 0.5 206 207 # weights 208 mcreate m1 3 4 209 m1[0][0] = 0.2 210 m1[1][0] = -0.2 211 m1[2][0] = -0.3 212 213 m1[0][1] = -0.6 214 m1[1][1] = 0.5 215 m1[2][1] = -0.1 216 217 m1[0][2] = -0.2 218 m1[1][2] = 0.2 219 m1[2][2] = -0.5 220 221 m1[0][3] = 0.4 222 m1[1][3] = -0.5 223 m1[2][3] = -0.7 224 225 mcreate m2 4 3 226 m2[0][0] = 0.8 227 m2[1][0] = -0.4 228 m2[2][0] = -0.5 229 m2[3][0] = 0.3 230 231 m2[0][1] = -0.2 232 m2[1][1] = -0.5 233 m2[2][1] = 0.1 234 m2[3][1] = 0.1 235 236 m2[0][2] = 0.2 237 m2[1][2] = -0.2 238 m2[2][2] = 0.5 239 m2[3][2] = -0.1 240 241 # set weights and biases 242 nnet set t1 m1 v1 m1 v1 243 244 # generate an input set spanning the range -5 to +5 245 246 create n 0 10000 247 set x0 = 10*rnd(n) - 5.0 248 set x1 = 10*rnd(n) - 5.0 249 set x2 = 10*rnd(n) - 5.0 250 251 # get output vectors the these input vectors 252 nnet apply t1 x0 x1 x2 y0 y1 y2 253 254 # nnet create tn 3 4 3 -large-weight-initializer 255 nnet create tn 3 4 3 256 257 # nnet train tn x0 x1 x2 y0 y1 y2 -Nmini $Nmini -Nepoch $Nepoch -eta $eta -lambda 0.1 258 nnet train tn x0 x1 x2 y0 y1 y2 -Nmini $Nmini -Nepoch $Nepoch -eta $eta -lambda 0.0 -quadratic-cost 259 260 nnet apply tn x0 x1 x2 Y0 Y1 Y2 261 262 set dy0 = y0 - Y0 263 set dy1 = y1 - Y1 264 set dy2 = y2 - Y2 265 266 vstat dy0 267 $yp = $MAX 268 $ym = $MIN 269 270 vstat dy1 271 $yp = max ($MAX , $yp) 272 $ym = min ($MIN , $ym) 273 274 vstat dy2 275 $yp = max ($MAX , $yp) 276 $ym = min ($MIN , $ym) 277 # $yp = 0.02; $ym = -0.02 278 279 style -pt circle -sz 2; 280 lim x0 $ym $yp; clear; box; 281 plot -c blue x0 dy0; 282 plot -c red x0 dy1 283 plot -c black x0 dy2 284 end 285
Note:
See TracChangeset
for help on using the changeset viewer.
