Comments (4)
Hi!
short:
We also pad sequences to the same length, this is done in the as_matrix
function.
long:
The padding is usually done out of one of two reasons:
- to put several strings in one tensorflow tensor (matrix)
- to compensate for model's inability to process sequences of different length.
The model we want you to build is able to process sequences of arbitrary length greater than conv filter size, so the only reason is (1.).
Instead of padding all data to a fixed length, we pad sequences when the batch is formed (in as_matrix
function). For instance, if there are three sentences in batch, their lengths being [3, 7, 5], they all will be padded to length=7.
However, if the next batch has different sequence lengths, they will be padded to a maximum of batch's sequence lengths.
The default network architecture is applicable to a batch of arbitrary length:
- first you apply convolutions/pooling which are applied to each patch of arbitrarily long sequence
- then you take whatever is left after convolution and do global max/average pooling, computing max/mean over time for each channel. Thus if convolution output shape was [batch_size, time, num_filters], it will be reduced to [batch_size, num_filters] and will become length independent.
- finally you apply dense layers to this fixed size representation
The only catch is that input must be long enough to apply convolutions. This should not be a problem if you use filter sizes of 2 or 3. For larger filters, please pad shorter sequences by either setting as_matrix(..., max_length=your_max_length)
or just manually add dots (. . . . .
) to shorter job titles.
from nlp_course.
Thank you very much for your detailed answer.
"This should not be a problem if you use filter sizes of 2 or 3."-Did you mean use square filter of the conv layer? If use a square filter then I know how to solve the problem.
However, I read the paper A Sensitivity Analysis of (and Practitioners' Guide to) Convolutional Neural Networks for Sentence Classification. And in section 2.1, the author said "Because rows represent discrete symbols (namely, words), it is reasonable to use filters with widths equal to the dimensionality of the word vectors (i.e., d)." I think it's reasonable to use filters with widths equal to the dimensionality of the word vectors. Will it reduce the interpretability of the network, if we use suqare filters?
Thank you again for your answer!
from nlp_course.
In this particular case we use 1D convolutions, so our filters are not squares, they're just 1d "stripes".
You can also consider this to be equivalent to using filters of dimension [vector_size x width] where vector size equals length of word embedding vectors and width is something around 2 or 3.
For this task it doesn't make much sense to use filter width equal to vector size because
- vector size can be large, several hundreds
- job title may contain 2-20 tokens, which is much smaller than vector size
from nlp_course.
from nlp_course.
Related Issues (20)
- week_2 seminar.ipynb
- week-5 readme broken link HOT 1
- solution HOT 2
- A question of bow_vocabulary in w2_homework_part1
- Please add reference for negative sampling
- Solution to homework? HOT 1
- requirement.txt HOT 1
- Week02 seminar.ipynb broken link
- 05_seminar: error - unexpected keyword argument 'input_ids'
- the classfication assignment dowload error.
- Missing word in text about residual connections
- Error in the formula from week 1 in lecture slides.
- can't download the data HOT 3
- Help with seminar on conversation HOT 2
- [question] tools for creating graphics HOT 3
- In pytorch week02_classification seminar bonus part don't work HOT 2
- is there any discussion group? HOT 2
- download data... 403 Forbidden HOT 3
- Homework
- Download uk and ru embeddings by wget command in Google Colab (week01_embeddings/homework) HOT 1
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 nlp_course.