# AI News, Use TensorFlow reshape To Change The Shape Of A Tensor ## Use TensorFlow reshape To Change The Shape Of A Tensor

We start by importing TensorFlow as tf.

In this video, we're going to use tf.reshape to change the shape of a TensorFlow tensor as long as the number of elements stay the same.

Let's start out with an initial TensorFlow constant tensor shaped 2x3x4 with numerical integer values between 1 and 24, all of whom have the data type of int32.

[ 1, 2, 3, 4],

[ 5, 6, 7, 8],

[ 9, 10, 11, 12]

[13, 14, 15, 16],

[17, 18, 19, 20],

[21, 22, 23, 24],

So we use tf.constant, we have our 2x3x4 tensor, we have the data type as int32, and we see the numbers are 1, 2, 3, 4, all the way through 24, and we assign it to the Python variable, tf_initial_tensor_constant.

For the first example, let's go from a tensor whose shape is 2x3x4 to a tensor whose shape is 2x12.

Note that the number of elements will stay the same as 2 x 3 x 4 is 24 and 2 x 12 is 24.

For the second example, let's change a tensor whose shape is 2x3x4 to a tensor whose shape is 2x3x2x2.

Note that the number of elements will stay the same as 2 x 3 x 4 is 24 and 2 x 3 x 2 x 2 is 24 as well.

For the third example, we're going to change a TensorFlow tensor whose shape is 2x3x4 to a vector of 24 elements.

We see that it's a TensorFlow tensor, we see that the shape is (24,), that means it's going to be a vector, the data type is int32.

We see that it's a 2x3x4 tensor, the numbers go from 1 to 24, and none of them have decimal points so we know that they're int32 numbers.

Perfect - we were able to use tf.reshape to change the shape of a TensorFlow tensor as long as the number of elements stay the same.

In this video, we're going to use tf.reshape to change the shape of a TensorFlow tensor as long as the number of elements stay the same.

Let's start out with an initial TensorFlow constant tensor shaped 2x3x4 with numerical integer values between 1 and 24, all of whom have the data type of int32.

[ 1, 2, 3, 4],

[ 5, 6, 7, 8],

[ 9, 10, 11, 12]

[13, 14, 15, 16],

[17, 18, 19, 20],

[21, 22, 23, 24],

So we use tf.constant, we have our 2x3x4 tensor, we have the data type as int32, and we see the numbers are 1, 2, 3, 4, all the way through 24, and we assign it to the Python variable, tf_initial_tensor_constant.

For the first example, let's go from a tensor whose shape is 2x3x4 to a tensor whose shape is 2x12.

Note that the number of elements will stay the same as 2 x 3 x 4 is 24 and 2 x 12 is 24.

For the second example, let's change a tensor whose shape is 2x3x4 to a tensor whose shape is 2x3x2x2.

Note that the number of elements will stay the same as 2 x 3 x 4 is 24 and 2 x 3 x 2 x 2 is 24 as well.

For the third example, we're going to change a TensorFlow tensor whose shape is 2x3x4 to a vector of 24 elements.

We see that it's a 2x3x4 tensor, the numbers go from 1 to 24, and none of them have decimal points so we know that they're int32 numbers.

Perfect - we were able to use tf.reshape to change the shape of a TensorFlow tensor as long as the number of elements stay the same.

Training/Testing on our Data - Deep Learning with Neural Networks and TensorFlow part 7

Welcome to part seven of the Deep Learning with Neural Networks and TensorFlow tutorials. We've been working on attempting to apply our recently-learned ...

A.I. Experiments: Visualizing High-Dimensional Space

Check out to learn more. This experiment helps visualize what's happening in machine learning. It allows coders to see and explore ..

Deep Learning with Tensorflow - Introduction to Convolutional Networks

Enroll in the course for free at: Deep Learning with TensorFlow Introduction The majority of data ..

TensorFlow Tutorial #06 CIFAR-10

How to make a Convolutional Neural Network for the CIFAR-10 data-set.

Continuously Train & Deploy Spark ML and Tensorflow AI Models from Jupyter Notebook to Production

Notebook: ...

Tensorflow Trained Keras MNIST for iOS 11 using Core ML

Edit* - source is now available at So after having attended WWDC and hearing a lot of developers asking how can ..

Tensorflow 20.2 RNN lstm 循环神经网络 (分类例子) (神经网络 教学教程tutorial)

Mobile and Embedded TensorFlow (TensorFlow Dev Summit 2017)

Did you know that TensorFlow models can be deployed in iOS and Android apps, and even run on Raspberry Pi? In this talk Pete Warden will go through ...

Keynote (TensorFlow Dev Summit 2017)

Jeff Dean, Rajat Monga, and Megan Kacholia delivered the keynote address at the inaugural TensorFlow Dev Summit. They discuss: - The origins of ...

TensorFlow and Deep Learning without a PhD, Part 1 (Google Cloud Next '17)

With TensorFlow, deep machine learning transitions from an area of research to mainstream software engineering. In this video, Martin Gorner demonstrates ...