x∈(-2π,2π)
x = tf.reshape(x, [-1, 1])
z = tf.layers.dense(x, middle_units, tf.nn.relu)
z = tf.layers.dense(z, middle_units//8, tf.nn.tanh)
y = tf.layers.dense(z, 1)
self.y_predict = tf.reshape(y, [-1])
self.y = tf.placeholder(tf.float32, [None], 'y')
loss = (self.y_predict - self.y) ** 2
loss = tf.reduce_mean(loss)
x∈(-2π,2π)
x = tf.layers.conv2d(
inputs=x, filters=16, kernel_size=[4, 4], padding="same", activation=tf.nn.relu)
x = tf.layers.max_pooling2d(x,pool_size=[4,4],strides=[4,4],padding='SAME')
z = tf.reshape(x, [-1, 1])
y = tf.layers.dense(z, 1)
self.y_predict = tf.reshape(y, [-1])
self.y = tf.placeholder(tf.float32, [None], 'y')
loss = (self.y_predict - self.y) ** 2
loss = tf.reduce_mean(loss)
有点离谱,CNN拟合不了sinx?还是哪里错了?



