MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _train

Method _train

tensorflow/python/layers/normalization_test.py:67–93  ·  view source on GitHub ↗
(self,
             checkpoint_path,
             shape,
             use_gpu,
             is_fused,
             restore=False,
             freeze_mode=False,
             dtype=dtypes.float32)

Source from the content-addressed store, hash-verified

65 return loss, train_op, saver
66
67 def _train(self,
68 checkpoint_path,
69 shape,
70 use_gpu,
71 is_fused,
72 restore=False,
73 freeze_mode=False,
74 dtype=dtypes.float32):
75 ops.reset_default_graph()
76 graph = ops.get_default_graph()
77 with self.session(graph=graph, use_gpu=use_gpu) as sess:
78 image = array_ops.placeholder(dtype=dtype, shape=shape)
79 loss, train_op, saver = self._simple_model(image, is_fused, freeze_mode)
80 if restore:
81 saver.restore(sess, checkpoint_path)
82 else:
83 self.evaluate(variables.global_variables_initializer())
84 np.random.seed(0)
85 for _ in range(2):
86 image_val = np.random.rand(*shape).astype(dtype.as_numpy_dtype)
87 sess.run([loss, train_op], feed_dict={image: image_val})
88 if restore:
89 all_vars = ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)
90 all_vars_values = [var.eval() for var in all_vars]
91 return all_vars_values
92 else:
93 saver.save(sess, checkpoint_path)
94
95 def _infer(self, checkpoint_path, image_val, shape, use_gpu, is_fused):
96 dtype = image_val.dtype

Callers 2

_trainEvalSequenceMethod · 0.95
_testCheckpointMethod · 0.95

Calls 12

_simple_modelMethod · 0.95
randMethod · 0.80
rangeFunction · 0.50
sessionMethod · 0.45
placeholderMethod · 0.45
restoreMethod · 0.45
evaluateMethod · 0.45
seedMethod · 0.45
runMethod · 0.45
get_collectionMethod · 0.45
evalMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected