TensorFlow 1.0 对比试验 用CNN or dense 层拟合 sinx函数 20211123

TensorFlow 1.0 对比试验 用CNN or dense 层拟合 sinx函数 20211123,第1张

TensorFlow 1.0 对比试验 用CNN or dense 层拟合 sinx函数 20211123 三层全连接神经网络拟合sinx:

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)


CNN 拟合 sinx:

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?还是哪里错了?

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5595175.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存