Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word2Vec Sequence contains no matching element #50

Open
AdnanSalah84 opened this issue May 4, 2021 · 4 comments
Open

Word2Vec Sequence contains no matching element #50

AdnanSalah84 opened this issue May 4, 2021 · 4 comments

Comments

@AdnanSalah84
Copy link

Hi folks,

I am using word2vec and I have added textfile instead of URL Web Download (text8.zip). The rest of the code is the same as the example written in word2vec.

...............
...............
// code omitted
...............
...............

int wordId = 0;
//text_words = File.ReadAllText($"word2vec{Path.DirectorySeparatorChar}text8").Trim().ToLower().Split();

string textFile = @"c:\...........\MyData.txt";
text_words = File.ReadAllText(textFile).Trim().ToLower().Split();

...............
...............
// code omitted
...............
...............

Here is my sample data text file (MyData.txt) as below:

This is Singapore and one two three four five and Test123 Kings are brave and Queens are beautiful Singapore is a really expensive country but really beautiful country and modern city
This is Malaysia and one two three four five and Test123 Kings are brave and Queens are beautiful Malaysia is a very old country but really beautiful country and old fashion city
This is Singapore and one two three four five and Test123 Kings are brave and Queens are beautiful Singapore is a really expensive country but really beautiful country and modern city
This is Malaysia and one two three four five and Test123 Kings are brave and Queens are beautiful Malaysia is a very old country but really beautiful country and old fashion city

The reading path file is working but I am getting an error message and it says:

graph\word2vec.meta already exists.
Words count: 129
Unique words: 27
Vocabulary size: 2
Most common words: UNK 0 113, and 1 16
2021-05-04 10:32:28.137672: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Step 1, Average Loss= 610.5444
Evaluation...
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at TensorFlowNET.Examples.Word2Vec.Run() in C:\********************\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\TextProcessing\Word2Vec.cs:line 114
   at TensorFlowNET.Examples.Program.RunExamples(String key, IExample[] examples) in C:\Users\Adnan Salahuddin\Desktop\TensorFlow\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\Program.cs:line 89
5/4/2021 5:32:29 AM Completed Word2Vec
Example: Word2Vec is Failed!
TensorFlow Binary v2.4.1
TensorFlow.NET v0.40.1.0
TensorFlow.Keras v0.5.1.0

I tried many times to fix this issue but still no clue. Could you please help me to solve this issue?

Thanking in anticipation

@Oceania2018
Copy link
Member

Can you try to add the sample size to like 100 lines of text at least.

@AdnanSalah84
Copy link
Author

I did and same error

graph\word2vec.meta already exists.
Words count: 3574
Unique words: 27
Vocabulary size: 28
Most common words: UNK 0 0, and 1 440, is 2 220, are 3 220, beautiful 4 220, country 5 220, really 6 165, this 7 110, singapore 8 110, one 9 110
2021-05-04 17:04:46.148202: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Step 1, Average Loss= 428.7090
Evaluation...
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at TensorFlowNET.Examples.Word2Vec.Run() in C:\Users\Adnan Salahuddin\Desktop\TensorFlow\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\TextProcessing\Word2Vec.cs:line 114
   at TensorFlowNET.Examples.Program.RunExamples(String key, IExample[] examples) in C:\Users\Adnan Salahuddin\Desktop\TensorFlow\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\Program.cs:line 89
5/4/2021 12:04:47 PM Completed Word2Vec
Example: Word2Vec is Failed!

MyData.txt

@AdnanSalah84
Copy link
Author

Updated MyData.txt file!

graph\word2vec.meta already exists.
Words count: 249891
Unique words: 23642
Vocabulary size: 2005
Most common words: UNK 0 42278,  1 47240, the 2 6279, and 3 5479, to 4 4723, i 5 4403, of 6 3721, my 7 3114, a 8 2975, you 9 2449
2021-05-05 09:58:39.631276: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-05-05 09:58:39.765438: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 37708000 exceeds 10% of free system memory.
2021-05-05 09:58:39.765775: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 37708000 exceeds 10% of free system memory.
Step 1, Average Loss= 537.0739
Evaluation...
2021-05-05 09:58:40.375849: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 37708000 exceeds 10% of free system memory.
2021-05-05 09:58:40.399673: W tensorflow/core/framework/cpu_allocator_impl.cc:80] Allocation of 37708000 exceeds 10% of free system memory.
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at TensorFlowNET.Examples.Word2Vec.Run() in C:\Users\Adnan Salahuddin\Desktop\TensorFlow\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\TextProcessing\Word2Vec.cs:line 114
   at TensorFlowNET.Examples.Program.RunExamples(String key, IExample[] examples) in C:\Users\Adnan Salahuddin\Desktop\TensorFlow\SciSharp-Stack-Examples\src\TensorFlowNET.Examples\Program.cs:line 89
5/5/2021 4:58:41 AM Completed Word2Vec
Example: Word2Vec is Failed!

MyData.txt

@AdnanSalah84
Copy link
Author

Dear,

I am waiting for your response!

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants