<s> '''<STR_LIT>''' <EOL> import climate <EOL> import logging <EOL> import matplotlib . pyplot as plt <EOL> import numpy as np <EOL> import theanets <EOL> climate . enable_default_logging ( ) <EOL> COLORS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> BATCH_SIZE = <NUM_LIT:2> <EOL> TAU = <NUM_LIT:2> * np . pi <EOL> T = np . linspace ( <NUM_LIT:0> , TAU , <NUM_LIT> ) <EOL> SIN = sum ( c * np . sin ( TAU * f * T ) for c , f in ( ( <NUM_LIT:2> , <NUM_LIT> ) , ( <NUM_LIT:3> , <NUM_LIT> ) , ( <NUM_LIT:4> , <NUM_LIT> ) ) ) <EOL> ZERO = np . zeros ( ( BATCH_SIZE , len ( T ) , <NUM_LIT:1> ) , '<STR_LIT:f>' ) <EOL> WAVES = np . concatenate ( [ SIN [ None , : , None ] ] * BATCH_SIZE , axis = <NUM_LIT:0> ) . astype ( '<STR_LIT:f>' ) <EOL> _ , ( wave_ax , learn_ax ) = plt . subplots ( <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> wave_ax . plot ( T , SIN , '<STR_LIT::>' , label = '<STR_LIT>' , alpha = <NUM_LIT> , color = '<STR_LIT>' ) <EOL> for i , layer in enumerate ( ( <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT:relu>' , diagonal = <NUM_LIT:0.5> ) , <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT:relu>' , rate = '<STR_LIT>' , diagonal = <NUM_LIT:0.5> ) , <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT>' ) , <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT:relu>' ) , <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT>' ) , <EOL> dict ( form = '<STR_LIT>' , activation = '<STR_LIT>' , periods = ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:16> , <NUM_LIT:64> ) ) ) ) : <EOL> name = layer [ '<STR_LIT>' ] <EOL> layer [ '<STR_LIT:size>' ] = <NUM_LIT:64> <EOL> logging . info ( '<STR_LIT>' , name ) <EOL> net = theanets . recurrent . Regressor ( [ <NUM_LIT:1> , layer , <NUM_LIT:1> ] ) <EOL> losses = [ ] <EOL> for tm , _ in net . itertrain ( [ ZERO , WAVES ] , <EOL> monitor_gradients = True , <EOL> batch_size = BATCH_SIZE , <EOL> algorithm = '<STR_LIT>' , <EOL> learning_rate = <NUM_LIT> , <EOL> momentum = <NUM_LIT> , <EOL> min_improvement = <NUM_LIT> ) : <EOL> losses . append ( tm [ '<STR_LIT>' ] ) <EOL> prd = net . predict ( ZERO ) <EOL> wave_ax . plot ( T , prd [ <NUM_LIT:0> , : , <NUM_LIT:0> ] . flatten ( ) , label = name , alpha = <NUM_LIT> , color = COLORS [ i ] ) <EOL> learn_ax . plot ( losses , label = name , alpha = <NUM_LIT> , color = COLORS [ i ] ) <EOL> for ax in [ wave_ax , learn_ax ] : <EOL> ax . xaxis . tick_bottom ( ) <EOL> ax . yaxis . tick_left ( ) <EOL> ax . spines [ '<STR_LIT>' ] . set_color ( '<STR_LIT:none>' ) <EOL> ax . spines [ '<STR_LIT:right>' ] . set_color ( '<STR_LIT:none>' ) <EOL> ax . spines [ '<STR_LIT>' ] . set_position ( ( '<STR_LIT>' , <NUM_LIT:6> ) ) <EOL> ax . spines [ '<STR_LIT:left>' ] . set_position ( ( '<STR_LIT>' , <NUM_LIT:6> ) ) <EOL> wave_ax . set_ylabel ( '<STR_LIT>' ) <EOL> wave_ax . set_xlabel ( '<STR_LIT>' ) <EOL> learn_ax . set_ylabel ( '<STR_LIT>' ) <EOL> learn_ax . set_xlabel ( '<STR_LIT>' ) <EOL> learn_ax . grid ( True ) <EOL> plt . legend ( ) <EOL> plt . show ( ) </s>
