Пример #1
0
    def __init__(self, sess, network_params):

        self._sess = sess

        self._params = network_params

        self._device = self._params['device']

        self._tf_sumry_wrtr = None

        if network_params['write_summary']:
            if 'summary_dir' in network_params:
                summary_dir = network_params['summary_dir']
            else:
                summary_dir = None
            self._tf_sumry_wrtr = TfSummaryWriter(tf_session=sess,
                                                  summary_dir=summary_dir)

        with tf.device(self._device):

            if self._params['write_summary']:
                tf.global_variables_initializer().run()

            self._mdn = MixtureDensityNetwork(
                network_params, tf_sumry_wrtr=self._tf_sumry_wrtr)

            self._mdn._init_model()
            self._net_ops = self._mdn._ops

            self._init_op = tf.global_variables_initializer()

            self._saver = tf.train.Saver()
Пример #2
0
    def __init__(self, sess, network_params):

        self._sess = sess

        self._params = network_params

        self._device = self._params['device']

        self._tf_sumry_wrtr = None

        self._optimiser = network_params['optimiser']

        self._data_configured = False

        if network_params['write_summary']:
            if 'summary_dir' in network_params:
                summary_dir = network_params['summary_dir']
            else:
                summary_dir = None
            
            self._tf_sumry_wrtr = TfSummaryWriter(tf_session=sess,summary_dir=summary_dir)
            cuda_path = '/usr/local/cuda/extras/CUPTI/lib64'

            curr_ld_path = os.environ["LD_LIBRARY_PATH"]

            if not cuda_path in curr_ld_path.split(os.pathsep):
                print "Enviroment variable LD_LIBRARY_PATH does not contain %s"%cuda_path
                print "Please add it, else the program will crash!"
                raw_input("Press Ctrl+C")
                # os.environ["LD_LIBRARY_PATH"] = curr_ld_path + ':'+cuda_path

        with tf.device(self._device):
            self._net_ops = tf_model(dim_input=network_params['dim_input'],
                                     dim_output=network_params['dim_output'],
                                     loss_type='quadratic',
                                     cnn_params=network_params['cnn_params'], 
                                     fc_params=network_params['fc_params'],
                                     optimiser_params=network_params['optimiser'],
                                     tf_sumry_wrtr=self._tf_sumry_wrtr)

            self._init_op = tf.initialize_all_variables()

            self._saver = tf.train.Saver()
Пример #3
0
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import sys

import tensorflow as tf
from aml_dl.utilities.tf_summary_writer import TfSummaryWriter
from tensorflow.examples.tutorials.mnist import input_data

FLAGS = None

sess = tf.InteractiveSession()
tf_sum_wrtr = TfSummaryWriter(tf_session=sess)


def train():
    # Import data
    mnist = input_data.read_data_sets(FLAGS.data_dir,
                                      one_hot=True,
                                      fake_data=FLAGS.fake_data)
    # Create a multilayer model.

    # Input placeholders
    with tf.name_scope('input'):
        x = tf.placeholder(tf.float32, [None, 784], name='x-input')
        y_ = tf.placeholder(tf.float32, [None, 10], name='y-input')

    with tf.name_scope('input_reshape'):