Comments (1)
I know it can be frustrating to learn these things. But it would be best to ask this type of question on StackOverflow because it is a general question related to TensorFlow, and the answer could have benefited more people.
You also don't mention which tutorial this is from. It looks like Tutorial #2, but it was 6 months since I wrote that one, so it is a bit much to expect me to clearly remember the details of that tutorial.
In general:
A 4-dim tensor has shape [batch, height, width, channel]. For example, we could have a tensor with shape [10, 80, 120, 3] which means the batch has 10 images, each of which are 80 pixels high and 120 pixels wide, with 3 channels (e.g. RGB colours).
The word 'stride' is similar in meaning to a step-size. It means how much should the index be incremented in each of those dimensions when we move the convolutional filters across the input tensor. The first and last strides have to be 1. This might seem like a strange design choice by the TensorFlow team, because there is no need to have a parameter that you cannot change. Anyway, you must set them to 1, which means that we increment the indices 1 for the batch-number and 1 for the colour-channel.
If you were to set the last one to 3, then you would increment the index for the colour-channel by 3 every time you move the convolutional filter, which means that you would only use one of the colour-channels and skip the other 2.
So the other numbers in the stride, e.g. [1, H, W, 1] would mean that after calculating each convolution (i.e. dot-product of the conv-filter with a small part of the input tensor), we move the conv-filter H pixels in the 2nd dimension, and we move W pixels in the 3rd dimension of the input tensor. Then we calculate another dot-product with the same conv-filter for the new position in the input tensor.
Why are H and W set to 1 in this tutorial? Because we instead use max-pooling to downsample the images. As I recall, one of the exercises in Tutorial #2 or #3 is to replace the max-pooling with a stride in the conv-layer and see if that changes the results.
It might be useful to watch the video for Tutorial #2 again and also try and do the exercises.
I would also suggest adding print-statements to the tutorial, so you can see the shape of the tensors that are being passed around.
In the future, please post general questions about TensorFlow on StackOverflow so it can help more people.
from tensorflow-tutorials.
Related Issues (20)
- when i was trying to run this code in pycharm it unables to download inception package and it results to an error ImportError: No module named 'inception' so please help me to overcome on this issue HOT 1
- Tutorial 23: Memory Error HOT 1
- ValueError: Unknown loss function:sparse_cross_entropy HOT 2
- Tutorial 21 Already Exists Error HOT 1
- 23_Time-Series-Prediction.ipynb - Predicting future values when have no test data? HOT 2
- Deprecated scipy libraries HOT 3
- acc = sess.run(accuracy, feed_dict={x: mnist.test.images, y: mnist.test.Lables}) AttributeError: 'DataSet' object has no attribute 'Lables' HOT 2
- using Elmo embedding layer in image captioning model ( Tutorial #22) HOT 1
- Image Caption works poorly HOT 6
- Tutorial 20 ValueError in Keras HOT 3
- TensorFlow 2.0 HOT 3
- Now how to forecast the future without knowing the known values? HOT 2
- AttributeError: module 'tensorflow' has no attribute 'gfile' in style transfer notebook HOT 3
- model.prediction does not match model.evaluation loss error HOT 3
- Tutorial 23 Error: Supplying multiple axes to axis is no longer supported. HOT 1
- ValueError: could not convert string to float: '28-12-2017'. I am training the time series prediction model on stock market data set and faced this error HOT 1
- issue when implementing image caption model HOT 4
- module 'tensorflow.python.ops.variable_scope' has no attribute '_VARSCOPE_KEY' HOT 2
- Korean translation HOT 2
- Tutorial 22_Image_Captioning.ipynb is not working in Colab because of disk space limit HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflow-tutorials.