Expected more than 1 value per channel when training
See original GitHub issueI am following the instructions to fit the model. However, I am getting this error: ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 50])
How to resolve this? What does this mean?
from contextualized_topic_models.models.ctm import CTM
from contextualized_topic_models.utils.data_preparation import TextHandler
from contextualized_topic_models.utils.data_preparation import bert_embeddings_from_file
from contextualized_topic_models.datasets.dataset import CTMDataset
handler = TextHandler("topic_tst.txt")
handler.prepare() # create vocabulary and training data
training_bert = bert_embeddings_from_file("topic_tst.txt", "./roberta-large-nli-mean-tokens")
training_dataset = CTMDataset(handler.bow, training_bert, handler.idx2token)
ctm = CTM(input_size=len(handler.vocab), bert_input_size=1024, inference_type="combined", n_components=50)
ctm.fit(training_dataset) # run the model
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Error: Expected more than 1 value per channel when training
The error is most likely thrown during training and if the current batch only contains a single sample. As you've explained this might...
Read more >Expected more than 1 value per channel? - Stack Overflow
This stops BatchNorm layers from updating their mean and variance, and allows input of just one sample. Use model.train() to resume training ......
Read more >Error: Expected more than 1 value per channel when training
It looks like you pass just 1 example during training. I'm guessing you've got a Batch Normalization layer in your network and it...
Read more >ValueError: Expected more than 1 value per channel when ...
When I run train.py file reported an error, and then modified the drop in the dataloader_ Last is true Running again is the...
Read more >error Expected more than 1 value per channel when training ...
So, the error occurs either if your batch size equals to 1, or if size of your dataset modulo batch size is equal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yay! That’s great!
I’m closing the issue then 😃
Update: Add other lines in the file does solve the problem. Thanks!