Closed ggerogiokas closed 4 years ago
Thanks @ggerogiokas for your question.
Since some examples may not have any neighbors (based on the similarity threshold chosen), you'd want to assign default values for all 'neighbor features' in your input layer before invoking the tf.io.parse_single_example() function. The default value will be the same as the one used for the sample's 'embedding' feature.
So, you'd change your example as follows (notice the default value for feature_spec[nbr_feature_key]
):
for i in range(HPARAMS.num_neighbors):
nbr_feature_key = '{}{}_{}'.format(NBR_FEATURE_PREFIX, i, 'embedding')
nbr_weight_key = '{}{}{}'.format(NBR_FEATURE_PREFIX, i, NBR_WEIGHT_SUFFIX)
feature_spec[nbr_feature_key] = tf.io.FixedLenFeature([HPARAMS.embedding_size], tf.float32, default_value=tf.constant(0, dtype=tf.float32, shape=[HPARAMS.embedding_size]))
Please let us know if you still run into issues.
Thanks that worked a charm. I forgot to set up the default values!
Hi all,
I am trying to run nsl on some of my own data but getting some issues reading the training data into the mlp model in my code.
The code is basically a combination of the first two tutorials.
I have my own embedding values and then use those to define a graph using your build_graph tool, running:
python nsl_repo/neural_structured_learning/tools/build_graph.py train.tfr train_graph.tsv --similarity_threshold 0.90 -v 1
I am using the embedding float values as features, 128 dimensions, and then also have labels plus ids byte value. Then, I want to try to classify 11 node types using a sequential MLP as a model.
But I keep getting the following error:
The following code generates the training and test TFRecord files:
The following code is where the NN model is defined.