tensorflow / tensorflow/probability

tf.keras.layers.Conv2D with and without tfpl.IndependentNormal | request for support

Open
#1,379 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I was trying to create a model with and without 'tfpl.IndependentNormal'.

tf.version is : 2.5.0 tfp.version is : 0.13.0

The codes are shared below.
_`def test_model(num_values, feature_size=256, name='test_submodel', tfpl_indep=False):
inputs = tf.keras.layers.Input(shape=(None, None, feature_size))
outputs = inputs
if tfpl_indep:
num_values=tfpl.IndependentNormal.params_size(num_values)
options = {
'kernel_size' : 3,
'strides' : 1,
'padding' : 'same',
'kernel_initializer' : tf.keras.initializers.RandomNormal(mean=0.0, stddev=0.01, seed=None),
'bias_initializer' : 'zeros'
}
outputs = tf.keras.layers.Conv2D( num_values, **options)(outputs)
if tfpl_indep:
outputs =tfpl.IndependentNormal(num_values)(outputs)
test_model=tf.keras.models.Model(inputs=inputs, outputs=outputs, name=name)
return test_model

#calling with and without tfpl.IndependentNormal
reg_model=test_model(num_values=4, tfpl_indep=False)
reg_model_tfpl_indep=test_model(num_values=4, tfpl_indep=True)

input=tf.keras.layers.Input(shape=( 90, 160, 256))

#passing the input to the model
reg_model_input=reg_model(input)
reg_model_input_data
#Works fine with output : KerasTensor(type_spec=TensorSpec(shape=(None, 90, 160, 4), dtype=tf.float32, name=None), name='test_submodel/conv2d_3/BiasAdd:0', description="created by layer 'test_submodel'")

reg_model_tfpl_indep_input=reg_model_tfpl_indep(input)
reg_model_tfpl_indep_input

#this does not give any response and not able to proceed_
`
It would be great if you can guide me to correct this for the tfpl model.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file or test. Start by reproducing the supplied test_model example with TensorFlow 2.5.0 and TensorFlow Probability 0.13.0, then inspect the tfpl.IndependentNormal.params_size and Keras model call path; done means identifying the compatibility or usage problem and documenting a minimal supported correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.