This repository was archived by the owner on Dec 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 10
10
import pickle
11
11
import re
12
12
import shutil
13
- # import ast
13
+ import ast
14
14
import sys
15
15
import tarfile
16
16
import time
@@ -231,25 +231,25 @@ def eval_layer(layer_kwargs):
231
231
layer_type = args .pop ('layer_type' )
232
232
if layer_type == "normal" :
233
233
generate_func (args )
234
- return eval ('tl.layers.' + layer_class )(** args )
234
+ return ast . literal_eval ('tl.layers.' + layer_class )(** args )
235
235
elif layer_type == "layerlist" :
236
236
ret_layer = []
237
237
layers = args ["layers" ]
238
238
for layer_graph in layers :
239
239
ret_layer .append (eval_layer (layer_graph ))
240
240
args ['layers' ] = ret_layer
241
- return eval ('tl.layers.' + layer_class )(** args )
241
+ return ast . literal_eval ('tl.layers.' + layer_class )(** args )
242
242
elif layer_type == "modellayer" :
243
243
M = static_graph2net (args ['model' ])
244
244
args ['model' ] = M
245
- return eval ('tl.layers.' + layer_class )(** args )
245
+ return ast . literal_eval ('tl.layers.' + layer_class )(** args )
246
246
elif layer_type == "keraslayer" :
247
247
M = load_keras_model (args ['fn' ])
248
248
input_shape = args .pop ('keras_input_shape' )
249
249
_ = M (np .random .random (input_shape ).astype (np .float32 ))
250
250
args ['fn' ] = M
251
251
args ['fn_weights' ] = M .trainable_variables
252
- return eval ('tl.layers.' + layer_class )(** args )
252
+ return ast . literal_eval ('tl.layers.' + layer_class )(** args )
253
253
else :
254
254
raise RuntimeError ("Unknown layer type." )
255
255
You can’t perform that action at this time.
0 commit comments