コード例 #1
0
import tensorflow as tf
from tensorflow.python import control_flow_ops
import my_lib.lib_building_blocks_nn_rbf as ml
import f_1D_data as data_lib
import time
#import winsound

def make_HBF2_model(x,W1,S1,C1,W2,S2,C2,phase_train):
    with tf.name_scope("layer1") as scope:
        layer1 = ml.get_Gaussian_layer(x,W1,S1,C1,phase_train)
    with tf.name_scope("layer2") as scope:
        layer2 = ml.get_Gaussian_layer(layer1,W2,S2,C2,phase_train)
    y = layer2
    return y

(X_train, Y_train, X_cv, Y_cv, X_test, Y_test) = data_lib.get_data_from_file(file_name='./f_1d_cos_no_noise_data.npz')
(N_train,D) = X_train.shape
D1 = 24
D2 = 24
(N_test,D_out) = Y_test.shape

x = tf.placeholder(tf.float32, shape=[None, D], name='x-input') # M x D
# Variables Layer1
#std = 1.5*np.pi
std = 0.1
W1 = tf.Variable( tf.truncated_normal([D,D1], mean=0.0, stddev=std, name='W1') ) # (D x D1)
S1 = tf.Variable(tf.constant(100.0, shape=[1], name='S1')) # (1 x 1)
C1 = tf.Variable( tf.truncated_normal([D1,1], mean=0.0, stddev=0.1, name='C1') ) # (D1 x 1)
# Variables Layer2
W2 = tf.Variable( tf.truncated_normal([D,D2], mean=0.0, stddev=std, name='W2') ) # (D x D1)
S2 = tf.Variable(tf.constant(100.0, shape=[1], name='S2')) # (1 x 1)
コード例 #2
0
import my_lib.lib_building_blocks_nn_rbf as ml
import f_1D_data as data_lib
import time
#import winsound


def make_HBF2_model(x, W1, S1, C1, W2, S2, C2, phase_train):
    with tf.name_scope("layer1") as scope:
        layer1 = ml.get_Gaussian_layer(x, W1, S1, C1, phase_train)
    with tf.name_scope("layer2") as scope:
        layer2 = ml.get_Gaussian_layer(layer1, W2, S2, C2, phase_train)
    y = layer2
    return y


(X_train, Y_train, X_cv, Y_cv, X_test, Y_test) = data_lib.get_data_from_file(
    file_name='./f_1d_cos_no_noise_data.npz')
(N_train, D) = X_train.shape
D1 = 24
D2 = 24
(N_test, D_out) = Y_test.shape

x = tf.placeholder(tf.float32, shape=[None, D], name='x-input')  # M x D
# Variables Layer1
#std = 1.5*np.pi
std = 0.1
W1 = tf.Variable(tf.truncated_normal([D, D1], mean=0.0, stddev=std,
                                     name='W1'))  # (D x D1)
S1 = tf.Variable(tf.constant(100.0, shape=[1], name='S1'))  # (1 x 1)
C1 = tf.Variable(tf.truncated_normal([D1, 1], mean=0.0, stddev=0.1,
                                     name='C1'))  # (D1 x 1)
# Variables Layer2