import numpy
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
运行之后cmd显示如下信息

确认为GPU

本文通过使用TensorFlow库实现矩阵乘法操作,并在GPU上运行,展示了如何利用GPU加速深度学习计算过程。代码中创建了两个矩阵并进行矩阵乘法运算,通过配置Session参数确保计算任务在GPU上执行。

4833

被折叠的 条评论
为什么被折叠?



