Exemple #1
0
    'Neural network structure: detection {} and modification {}'.format(
        pargs.dnet, pargs.mnet))
dlayers = list(map(int, pargs.dnet.split('-')))
mlayers = list(map(int, pargs.mnet.split('-')))
dact = list(map(tf_network.parse_act, pargs.dact.split('-')))
mact = list(map(tf_network.parse_act, pargs.mact.split('-')))
init_w = {'w': {'stddev': 0.1}, 'b': {'value': 0.5}}
x = tf.placeholder(tf.float32, shape=[None, dlayers[0]], name='x-input')
keep_prob = tf.placeholder(
    tf.float32, name='keep_prob_detector') if pargs.ddrop > 0.0 else None
keep_prob2 = tf.placeholder(
    tf.float32, name='keep_prob_modifier') if pargs.mdrop > 0.0 else None
y_, y = tf_network.build_network(dlayers,
                                 dact,
                                 init_weights=init_w,
                                 input_x_holder=x,
                                 dropout_holder=keep_prob,
                                 bn=pargs.bn,
                                 scope='detector/')[1:]
y2_, y2 = tf_network.build_network(mlayers,
                                   mact,
                                   init_weights=init_w,
                                   input_x_holder=x,
                                   dropout_holder=keep_prob2,
                                   bn=pargs.bn,
                                   scope='modifier/')[1:]
if pargs.mve:
    s = tf_network.build_network(mlayers,
                                 mact,
                                 init_weights=init_w,
                                 input_x_holder=x,
Exemple #2
0
import numpy as np
dtype_real = np.float32         # NOTE: if double precision, use float64
dtype_int  = np.int32           # NOTE: if int in C is 64bits, use int64
np.random.seed(1)

import tensorflow as tf
tf_sess = tf.InteractiveSession()

import tf_network
dlayers = list(map(int, tfopt['dnet'].split('-')))
mlayers = list(map(int, tfopt['mnet'].split('-')))
dact    = list(map(tf_network.parse_act, tfopt['dact'].split('-')))
mact    = list(map(tf_network.parse_act, tfopt['mact'].split('-')))
x       = tf.placeholder(tf.float32, shape=[None, dlayers[0]], name='x-input')
y_,  y  = tf_network.build_network(dlayers, dact, input_x_holder=x, bn=tfopt['bn'], is_training=False, scope='detector/')[1:]
y2_, y2 = tf_network.build_network(mlayers, mact, input_x_holder=x, bn=tfopt['bn'], is_training=False, scope='modifier/')[1:]
if tfopt['mve']:
	sd  = tf_network.build_network(mlayers, mact, input_x_holder=x, input_y_holder=y2_, bn=tfopt['bn'], is_training=False, scope='modifier_var/')[2]

tf_saver = tf.train.Saver()
modelfile = pargs.load + '/model.ckpt'
tf_saver.restore(tf_sess, modelfile)
print('Pre-trained model {} loaded\n'.format(modelfile))

import manta as mt
mt.tFluid    = FlagFluid
mt.tObstacle = FlagObstacle

nogui       = False
pause       = False