@@ -16,7 +16,7 @@ def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
16
16
layer_name = 'layer%s' % n_layer
17
17
18
18
# for tensorflow version < 0.12
19
- if int ((tf .__version__ ).split ('.' )[1 ]) < 12 :
19
+ if int ((tf .__version__ ).split ('.' )[1 ]) < 12 and int (( tf . __version__ ). split ( '.' )[ 0 ]) < 1 :
20
20
with tf .name_scope (layer_name ):
21
21
with tf .name_scope ('weights' ):
22
22
Weights = tf .Variable (tf .random_normal ([in_size , out_size ]), name = 'W' )
@@ -68,7 +68,7 @@ def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
68
68
with tf .name_scope ('loss' ):
69
69
loss = tf .reduce_mean (tf .reduce_sum (tf .square (ys - prediction ),
70
70
reduction_indices = [1 ]))
71
- if int ((tf .__version__ ).split ('.' )[1 ]) < 12 : # tensorflow version < 0.12
71
+ if int ((tf .__version__ ).split ('.' )[1 ]) < 12 and int (( tf . __version__ ). split ( '.' )[ 0 ]) < 1 : # tensorflow version < 0.12
72
72
tf .scalar_summary ('loss' , loss )
73
73
else : # tensorflow version >= 0.12
74
74
tf .summary .scalar ('loss' , loss )
@@ -77,20 +77,20 @@ def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
77
77
train_step = tf .train .GradientDescentOptimizer (0.1 ).minimize (loss )
78
78
79
79
sess = tf .Session ()
80
- if int ((tf .__version__ ).split ('.' )[1 ]) < 12 : # tensorflow version < 0.12
80
+ if int ((tf .__version__ ).split ('.' )[1 ]) < 12 and int (( tf . __version__ ). split ( '.' )[ 0 ]) < 1 : # tensorflow version < 0.12
81
81
merged = tf .merge_all_summaries ()
82
82
else : # tensorflow version >= 0.12
83
83
merged = tf .summary .merge_all ()
84
84
85
85
# tf.train.SummaryWriter soon be deprecated, use following
86
- if int ((tf .__version__ ).split ('.' )[1 ]) < 12 : # tensorflow version < 0.12
86
+ if int ((tf .__version__ ).split ('.' )[1 ]) < 12 and int (( tf . __version__ ). split ( '.' )[ 0 ]) < 1 : # tensorflow version < 0.12
87
87
writer = tf .train .SummaryWriter ('logs/' , sess .graph )
88
88
else : # tensorflow version >= 0.12
89
89
writer = tf .summary .FileWriter ("logs/" , sess .graph )
90
90
91
91
# tf.initialize_all_variables() no long valid from
92
92
# 2017-03-02 if using tensorflow >= 0.12
93
- if int ((tf .__version__ ).split ('.' )[1 ]) < 12 :
93
+ if int ((tf .__version__ ).split ('.' )[1 ]) < 12 and int (( tf . __version__ ). split ( '.' )[ 0 ]) < 1 :
94
94
init = tf .initialize_all_variables ()
95
95
else :
96
96
init = tf .global_variables_initializer ()
0 commit comments