-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtfmodel.py
More file actions
41 lines (33 loc) · 1.07 KB
/
tfmodel.py
File metadata and controls
41 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import tensorflow as tf
class TFModel(object):
def __init__(self, session=None, nid="tfm", input_data = None, verbose=True, reuse=False):
if not session:
session = tf.Session()
self._session = session
self.nid = nid # network id string
self._verbose = verbose
self._reuse = reuse
self._model = None
self._is_initialized = False # are the variables already initialized?
self._input_data = input_data
@property
def session(self):
return self._session
@property
def model(self):
return self._model
@property
def input_data(self):
return self._input_data
def _build_model(self):
pass
def eval(self):
pass
def _initialize_variables(self):
# initialize the variables if not done already
if not self._is_initialized:
# init = tf.global_variables_initializer()
init = tf.initialize_all_variables()
self._session.run(init)
self._is_initialized = True