# Confussion Feeding Data in MAP

**URL:** <https://discourse.edwardlib.org/t/confussion-feeding-data-in-map/259>\
**Category:** General\
**Created:** [July 24, 2017, 5:16pm UTC](https://discourse.edwardlib.org/t/confussion-feeding-data-in-map/259 "2017-07-24T17:16:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mig](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/mig/32/387_2.png) [@mig](https://discourse.edwardlib.org/u/mig)\
**Post date:** [July 24, 2017, 5:16pm UTC](https://discourse.edwardlib.org/t/confussion-feeding-data-in-map/259/1 "2017-07-24T17:16:09Z")

</div>

Hello,

would it be possible to know about the following: I do not understand what should be feed into the inference method and what should be feed at each update() into the inference method MAP.

**- Mixture Density Networks Tutorial:**  
Model:  
locs, scales, logits = neural\_network(X\_ph)  
…  
y = Mixture(cat=cat, components=components, value=tf.zeros\_like(y\_ph))

```
  Inference: WHY DOES IT NOT INCLUDE X_PH????
  inference = ed.MAP(data={y: y_ph})
  Update: Here we pass all the data.
  inference.update(feed_dict={X_ph: X_train, y_ph: y_train}) 

```

**I am trying to optimize the following problem:**  
_Model_:

```
    W_1 = tf.Variable(weights['W1'], name="W_1")
    W_2 = tf.Variable(weights['W2'], name="W_2")
    W_3 = tf.Variable(weights['W3'], name="W_3")
    W_out = tf.Variable(weights['Wout'], name="Wout")
    b_1 = tf.Variable(biases['b1'], name="b_1")
    b_2 = tf.Variable(biases['b2'], name="b_2")
    b_3 = tf.Variable(biases['b3'], name="b_3")
    X = tf.placeholder(tf.float32, [N, D], name="X")
    y_ph = tf.placeholder(tf.float32, [N, D], name="y_ph")
    y = Normal(loc=neural_network(X, W_1, W_2, W_3, W_out, b_1, b_2, b_3),
               scale=0.25 * tf.ones(N, 1), name="y")
    y = tf.reshape(y, [N, 1])

```

_Inference_:

```
 inference = ed.MAP([W_1, b_1, W_2, b_2, W_3, b_3, W_out], data={X: xx, y: y_ph}) 
 optimizer = tf.train.AdamOptimizer(5e-3)
 inference.initialize(optimizer=optimizer, var_list=tf.trainable_variables())
 sess = ed.get_session()
 tf.global_variables_initializer().run()
 n_epoch = 1000
 train_loss = np.zeros(n_epoch)
 for i in range(n_epoch):
      info_dict = inference.update(feed_dict={X: xx, y: yy})
      train_loss[i] = info_dict['loss']
      inference.print_progress(info_dict)
```

---

<div class="post-metadata">

**Author:** ![dustin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/dustin/32/134_2.png) [@dustin](https://discourse.edwardlib.org/u/dustin)\
**Post date:** [July 24, 2017, 6:19pm UTC](https://discourse.edwardlib.org/t/confussion-feeding-data-in-map/259/2 "2017-07-24T18:19:00Z")

</div>

> [@mig](#):
>
> Inference: WHY DOES IT NOT INCLUDE X\_PH???  
> inference = ed.MAP(data={y: y\_ph})  
> Update: Here we pass all the data.  
> inference.update(feed\_dict={X\_ph: X\_train, y\_ph: y\_train})

In `data`, you feed in random variables binded to their observations. Because MDN defines a conditional distribution `p(y | x)`, there is no random variable for `x`. That said, when in doubt you can feed in `X_ph: X_train` into MAP too—this is just a useful shortcut.

---

<div class="post-metadata">

**Author:** ![mig](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.edwardlib.org/mig/32/387_2.png) [@mig](https://discourse.edwardlib.org/u/mig)\
**Post date:** [July 24, 2017, 7:19pm UTC](https://discourse.edwardlib.org/t/confussion-feeding-data-in-map/259/3 "2017-07-24T19:19:20Z")

</div>

and how about passing variables for inference?

Is this form , ed.MAP([W\_1, b\_1, W\_2, b\_2, W\_3, b\_3, W\_out], data={X: xx, y: y\_ph}) the right way to write it ?

Thanks a lot,
