Answers.Body: <p>We can generalize both problem and solution by removing the specifics of housing.</p>
  
  <p><strong>Representing Forward Propagation</strong></p>
  
  <p>We have a function $f$ we wish to obtain via the training of an artificial network that produces a scalar result $s$, the sole dependent variable and the generalization of market price.</p>
  
  <p>$s = f(s_1, s_2, ..., s_k, c_1, c_2, ..., c_v)$</p>
  
  <p>The independent scalar variables $s_1$ through $s_k$ are the generalization of a constant number $k$ of property features from the tax authority, assessor's office, or inspection document.  The question calls this <em>structured data</em>, however it is questionable whether $k$ is truly effectively constant.  In normal practice, some of $s_i$ will be unassigned.  Since the question overlooks the additional complexity of missing scalars, so will this answer.</p>
  
  <p>The independent cube variables $c_1$ through $c_v$ are the generalizations of a variable number $v$ of property images from Google photography, real estate agents, buyers, sellers, and other potential sources.  The dimensions of each cube are horizontal and vertical positions and pixel structure element number.</p>
  
  <p>It is unlikely that the resolution values for each cube are uniform between samples in real life, which the question did not mention, so this answer will overlook that complexity and focus on the variability of $v$, the quantity of cubes representing images for a given example.  Since $v$ cannot meaningfully be either negative or infinite, we can assume $v$ to be a non-negative integer.</p>
  
  <p><strong>Terminology</strong></p>
  
  <p>The observational unit should not be considered the house or the property but an image of it, which may be a member of a camera location and orientation category relative to the elements of the property.  Each image capture is an observation, distinct in both Bergsonian and clock time.  Each item under evaluation is an <em>example</em> from the sample of all items, in this case, all properties in the region for which prediction is attempted.</p>
  
  <p><strong>Design of a Solution</strong></p>
  
  <p>Each of the $v$ cubes demonstrate zero or more additional features of the item being evaluated, real properties in the question's specific case.</p>
  
  <p>It may be reasonable to assume that such features may either positively or negative affect the example's label corresponding to the result $s$, but not both positively and negatively affect it.  If that is the case, we can aggregate the features across the set of cubes for each example under the reasonable assumption that there are no points of inflection.  Such may be reasonable because, for instance, a feature regarding the uniformity of paint coverage, lawn care, or roofing material may have no inflection point.  Such aspects of the property cannot be too uniform.  That makes the substitution straightforward.</p>
  
  <p>A reasonably versatile way to generalize the aggregation of directionally consistent function is using a substitution, which may be what the question meant by <em>feed in the embeddings of the image to your final model</em>.</p>
  
  <p>$s = f = f'(s_1, s_2, ..., s_k, v, h\big(v, \sum_{j = 1}^v g(c_j)\big)$</p>
  
  <p>Note the elements of this substitution.</p>
  
  <ul>
  <li>$h$ is a vector function that normalizes the distribution of each feature found in the feature vector before using it as a set of inputs to $f'$.</li>
  <li>$g$ is a generalization of the cube, with the input (independent variable) being a cube representing the image and with the output (dependent variable) being a vector of features extracted.</li>
  <li>$v$, the number of cubes (visual observations) is fed along with extracted features into the function $f'$, which can be realized through the convergence of a multilayer perceptron.</li>
  </ul>
  
  <p>If the images are grouped in terms of the location of the camera, then this principle can be applied iteratively, where $o$ is the number of distinct categories of camera orientation.  In this case, the pairs $(v_z, h_z)$ represent the cube quantity and feature aggregations for image camera location category $z$.</p>
  
  <p>$s = f = f'(s_1, s_2, ..., s_k, v_1, h_1, v_2, h_2, ... v_o, h_o)$</p>
  
  <p>Given sensible models $h$ and $g$, training for prediction is straightforward.</p>
  
  <p>Image feature extraction can be realized through ConvNet approaches such as OverFeat<sup>1</sup>, AlexNet<sup>2</sup>, CaffeNet<sup>3</sup>, GoogLeNet<sup>4</sup>, VGG 6<sup>5</sup> or PatreoNet<sup>6</sup>.  Tuning such models produces $g$.</p>
  
  <p>The nature of function $h$ may be homogeneous or heterogeneous across dimensions.  Each component of the feature vector arising from extraction can have applied to it a function such as any of these or others, where $q$ is the feature index, $p_{qi}$ is learning parameter i.</p>
  
  <ol>
  <li>$h_q(x) = x$</li>
  <li>$h_q(x) = \large{x^{p_{q1} + p_{q2} v}}$</li>
  <li>$h_q(x) = \log (x + p_{q1} v + p_{q2})$</li>
  <li>$h_q(x) = \large{\epsilon^x}$</li>
  <li>Others</li>
  </ol>
  
  <p>Scalar function 1 is best when the designer wishes the convergence during the training of $f'$ in such a way that normalization is accomplished in the net.  It is a good choice for features where its frequency of occurrence and magnitude are across the entire set of images for a given example item is roughly proportional to the resulting value of that item.</p>
  
  <p>Function 2 presents flexibility in normalization curvature with respect to the number of cubes.  Function 3 presents attenuation of the frequency of feature occurrence.  Function 4 presents compounding of feature effect with recurrence in the images of the same example.</p>
  
  <p>The key is then the selection of how to deal with the substitution in the training in terms of procedure and wiring of corrective signaling.  Procedurally, there are three options.</p>
  
  <ul>
  <li>Train both the ConvNet function $g$ and the multilayer perceptron function $f'$ together, extending the applicable principles of back-propagation and gradient descent.</li>
  <li>Extract features first, tuning the ConvNet corresponding to $g$ prior to training the network corresponding to $f'$.  The advantage of this approach is manual control over and interim evaluation of feature extraction.</li>
  <li>Use something similar to the mini-batch approach to find a balance between the above two extremes.</li>
  </ul>
  
  <p>&mdash;&mdash;&mdash;</p>
  
  <p><strong>Footnotes</strong></p>
  
  <p>[1] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus, Y. LeCun, Overfeat: Integrated recognition, localization and detection using convolutional networks, arXiv preprint arXiv:1312.6229v4</p>
  
  <p>[2] A. Krizhevsky, I. Sutskever, G. E. Hinton, Imagenet classification with deep convolutional neural networks, in: Neural Information Processing Systems, 2012, pp. 1106–1114</p>
  
  <p>[3] Y. Jia, E. Shelhamer, J. Donahue, S. Karayev, J. Long, R. Girshick, S. Guadarrama, T. Darrell, Caffe: Convolutional architecture for fast feature embedding, arXiv preprint arXiv:1408.5093</p>
  
  <p>[4] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, A. Rabinovich, Going deeper with convolutions, arXiv preprint arXiv:1409.4842</p>
  
  <p>[5] K. Simonyan, A. Zisserman, Very deep convolutional networks for large-scale image recognition, arXiv preprint arXiv:1409.1556</p>
  
  <p>[6] K. Nogueira,  W. O. Miranda,  J. A. Dos Santos,  Improving spatial feature representation from aerial scenes by using convolutional networks, in:  Graphics, Patterns and Images (SIBGRAPI), 2015 28th SIBGRAPI Conference on, IEEE, 2015, pp. 289–296.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-31T11:37:51.847Z
Answers.LastActivityDate: 2018-09-16T14:07:02.137Z
Answers.LastEditDate: 2018-09-16T14:07:02.137Z
Answers.UserDisplayName: Douglas Daseeco
Answers.Body: <p>I can think of 4 options:</p>
  
  <ol>
  <li><p>One option is to divide the data so that each data point only has one picture but we have multiple data points per one real estate with structured data duplicated. Then calculate the forecasts and average the resulting predicted price between data points belonging to one real estate. Here we probably assume that the quality of pictures is more important than what is being shot. </p></li>
  <li><p>The other option is to divide the pictures to categories: bedroom1, bathroom, bedroom2, kitchen and so on. Then for the missing pictures use a black square. This way you will be able to have multiple pictures in one data point.</p></li>
  <li><p>The third option would be to have places for the maximum amount of pictures and fill only the first pictures that are available. And the other pictures fill with black squares/Nans.</p></li>
  <li><p>The best option would probably be combining option number two and three. So you have categories and maximum number of pictures per category. So you will have four categories for bathroom1 if the maximum is 4 pictures of the first bathroom:</p>
  
  <p>Bathroom1_1, Bathroom1_2, Bathroom1_3, Bathroom1_4, Bedroom1_1, Bedroom1_2, Bedroom1_3, Bedroom2_1, Bedroom2_2 ... and so on.</p></li>
  </ol>
  
  <p>The gradient boosting algorithms are very good at working with missing values. So probably lightgbm and xgboost as last layers could give good results.</p>
  
  <p>So in the end you can check all the variants and even do ensembles from the variants that give the best results.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T07:47:36.590Z
Answers.Text: option 2,3, and 4 is overkilling, you have useless datas (blank/black images) !
Answers.UserDisplayName: Jérémy Blain
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T07:57:36.157Z
Answers.Text: According to my experience, boosting algorithms, like lightgbm and xgboost, significantly increase performance if you use rows with missing values instead of just removing them. Missing value is also an information. If there are not all photos of all rooms then I would suggest that the seller is hiding something. And the price should go down because the missing room could be in awful conditions.
Answers.UserDisplayName: keiv.fly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T15:02:28.213Z
Answers.Text: Maybe, but I'm not sure I like the blank images either in option 4, for example, say that the kitchen is gorgeous, but your algorithm punishes a single picture of the kitchen because of the blank 5 slots for kitchen pictures.
Answers.UserDisplayName: Ryan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T15:05:05.373Z
Answers.Text: I am also concerned about option 1. I like that it deals with a test set observation that can have more than the max number of images in the training set, which is a real concern, but I do worry that averaging would wash out a picture that could severely move price in one direction or the other.
Answers.UserDisplayName: Ryan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T16:36:40.123Z
Answers.Text: Blank does not mean punishment. It is for the algorithm to decide which empty picture to punish. Or it can learn to just use one picture that is present. If in your dataset one picture of a gorgeous kitchen has a high price then the algorithm will learn that one picture is enough.
Answers.UserDisplayName: keiv.fly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T07:43:26.413Z
Answers.LastActivityDate: 2018-08-23T07:43:26.413Z
Answers.UserDisplayName: keiv.fly
Body: <p>So suppose that you have a real estate appraisal problem. You have some structured data, and some images exterior of home, bedrooms, kitchen, etc. The number of pictures taken is variable per observational unit, i.e. the house.</p>
  <p>I understand the basics of combining an image processing neural net with tabular data for a single image. You chop off the final layer and feed in the embeddings of the image to your final model.</p>
  <p>How would one deal with variable number of images? Where your unit of observation can have between zero and infinity images (theoretically no upper bound on number of images in observation)?</p>
  
Tags: <deep-learning><image-recognition>
Title: Variable Number of Inputs to Neural Networks
UserDisplayName: Ryan
ThreadText: # Variable Number of Inputs to Neural Networks
  
  (Asked by: username_0 on 2018-08-22)
  
  So suppose that you have a real estate appraisal problem. You have some structured data, and some images exterior of home, bedrooms, kitchen, etc. The number of pictures taken is variable per observational unit, i.e. the house.
  
  I understand the basics of combining an image processing neural net with tabular data for a single image. You chop off the final layer and feed in the embeddings of the image to your final model.
  
  How would one deal with variable number of images? Where your unit of observation can have between zero and infinity images (theoretically no upper bound on number of images in observation)?
  
  **Tags:** deep-learning, image-recognition
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-08-31. Score: 1 | Accepted answer
  
  We can generalize both problem and solution by removing the specifics of housing.
  
  **Representing Forward Propagation**
  
  We have a function $f$ we wish to obtain via the training of an artificial network that produces a scalar result $s$, the sole dependent variable and the generalization of market price.
  
  $s = f(s\_1, s\_2, ..., s\_k, c\_1, c\_2, ..., c\_v)$
  
  The independent scalar variables $s\_1$ through $s\_k$ are the generalization of a constant number $k$ of property features from the tax authority, assessor's office, or inspection document. The question calls this *structured data*, however it is questionable whether $k$ is truly effectively constant. In normal practice, some of $s\_i$ will be unassigned. Since the question overlooks the additional complexity of missing scalars, so will this answer.
  
  The independent cube variables $c\_1$ through $c\_v$ are the generalizations of a variable number $v$ of property images from Google photography, real estate agents, buyers, sellers, and other potential sources. The dimensions of each cube are horizontal and vertical positions and pixel structure element number.
  
  It is unlikely that the resolution values for each cube are uniform between samples in real life, which the question did not mention, so this answer will overlook that complexity and focus on the variability of $v$, the quantity of cubes representing images for a given example. Since $v$ cannot meaningfully be either negative or infinite, we can assume $v$ to be a non-negative integer.
  
  **Terminology**
  
  The observational unit should not be considered the house or the property but an image of it, which may be a member of a camera location and orientation category relative to the elements of the property. Each image capture is an observation, distinct in both Bergsonian and clock time. Each item under evaluation is an *example* from the sample of all items, in this case, all properties in the region for which prediction is attempted.
  
  **Design of a Solution**
  
  Each of the $v$ cubes demonstrate zero or more additional features of the item being evaluated, real properties in the question's specific case.
  
  It may be reasonable to assume that such features may either positively or negative affect the example's label corresponding to the result $s$, but not both positively and negatively affect it. If that is the case, we can aggregate the features across the set of cubes for each example under the reasonable assumption that there are no points of inflection. Such may be reasonable because, for instance, a feature regarding the uniformity of paint coverage, lawn care, or roofing material may have no inflection point. Such aspects of the property cannot be too uniform. That makes the substitution straightforward.
  
  A reasonably versatile way to generalize the aggregation of directionally consistent function is using a substitution, which may be what the question meant by *feed in the embeddings of the image to your final model*.
  
  $s = f = f'(s\_1, s\_2, ..., s\_k, v, h\big(v, \sum\_{j = 1}^v g(c\_j)\big)$
  
  Note the elements of this substitution.
  
  * $h$ is a vector function that normalizes the distribution of each feature found in the feature vector before using it as a set of inputs to $f'$.
  * $g$ is a generalization of the cube, with the input (independent variable) being a cube representing the image and with the output (dependent variable) being a vector of features extracted.
  * $v$, the number of cubes (visual observations) is fed along with extracted features into the function $f'$, which can be realized through the convergence of a multilayer perceptron.
  
  If the images are grouped in terms of the location of the camera, then this principle can be applied iteratively, where $o$ is the number of distinct categories of camera orientation. In this case, the pairs $(v\_z, h\_z)$ represent the cube quantity and feature aggregations for image camera location category $z$.
  
  $s = f = f'(s\_1, s\_2, ..., s\_k, v\_1, h\_1, v\_2, h\_2, ... v\_o, h\_o)$
  
  Given sensible models $h$ and $g$, training for prediction is straightforward.
  
  Image feature extraction can be realized through ConvNet approaches such as OverFeat1, AlexNet2, CaffeNet3, GoogLeNet4, VGG 65 or PatreoNet6. Tuning such models produces $g$.
  
  The nature of function $h$ may be homogeneous or heterogeneous across dimensions. Each component of the feature vector arising from extraction can have applied to it a function such as any of these or others, where $q$ is the feature index, $p\_{qi}$ is learning parameter i.
  
  1. $h\_q(x) = x$
  2. $h\_q(x) = \large{x^{p\_{q1} + p\_{q2} v}}$
  3. $h\_q(x) = \log (x + p\_{q1} v + p\_{q2})$
  4. $h\_q(x) = \large{\epsilon^x}$
  5. Others
  
  Scalar function 1 is best when the designer wishes the convergence during the training of $f'$ in such a way that normalization is accomplished in the net. It is a good choice for features where its frequency of occurrence and magnitude are across the entire set of images for a given example item is roughly proportional to the resulting value of that item.
  
  Function 2 presents flexibility in normalization curvature with respect to the number of cubes. Function 3 presents attenuation of the frequency of feature occurrence. Function 4 presents compounding of feature effect with recurrence in the images of the same example.
  
  The key is then the selection of how to deal with the substitution in the training in terms of procedure and wiring of corrective signaling. Procedurally, there are three options.
  
  * Train both the ConvNet function $g$ and the multilayer perceptron function $f'$ together, extending the applicable principles of back-propagation and gradient descent.
  * Extract features first, tuning the ConvNet corresponding to $g$ prior to training the network corresponding to $f'$. The advantage of this approach is manual control over and interim evaluation of feature extraction.
  * Use something similar to the mini-batch approach to find a balance between the above two extremes.
  
  ———
  
  **Footnotes**
  
  [1] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus, Y. LeCun, Overfeat: Integrated recognition, localization and detection using convolutional networks, arXiv preprint arXiv:1312.6229v4
  
  [2] A. Krizhevsky, I. Sutskever, G. E. Hinton, Imagenet classification with deep convolutional neural networks, in: Neural Information Processing Systems, 2012, pp. 1106–1114
  
  [3] Y. Jia, E. Shelhamer, J. Donahue, S. Karayev, J. Long, R. Girshick, S. Guadarrama, T. Darrell, Caffe: Convolutional architecture for fast feature embedding, arXiv preprint arXiv:1408.5093
  
  [4] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, A. Rabinovich, Going deeper with convolutions, arXiv preprint arXiv:1409.4842
  
  [5] K. Simonyan, A. Zisserman, Very deep convolutional networks for large-scale image recognition, arXiv preprint arXiv:1409.1556
  
  [6] K. Nogueira, W. O. Miranda, J. A. Dos Santos, Improving spatial feature representation from aerial scenes by using convolutional networks, in: Graphics, Patterns and Images (SIBGRAPI), 2015 28th SIBGRAPI Conference on, IEEE, 2015, pp. 289–296.
  
  
  ---
  
  ### Answer by username_2 on 2018-08-23. Score: 0
  
  I can think of 4 options:
  
  1. One option is to divide the data so that each data point only has one picture but we have multiple data points per one real estate with structured data duplicated. Then calculate the forecasts and average the resulting predicted price between data points belonging to one real estate. Here we probably assume that the quality of pictures is more important than what is being shot.
  2. The other option is to divide the pictures to categories: bedroom1, bathroom, bedroom2, kitchen and so on. Then for the missing pictures use a black square. This way you will be able to have multiple pictures in one data point.
  3. The third option would be to have places for the maximum amount of pictures and fill only the first pictures that are available. And the other pictures fill with black squares/Nans.
  4. The best option would probably be combining option number two and three. So you have categories and maximum number of pictures per category. So you will have four categories for bathroom1 if the maximum is 4 pictures of the first bathroom:
  
     Bathroom1\_1, Bathroom1\_2, Bathroom1\_3, Bathroom1\_4, Bedroom1\_1, Bedroom1\_2, Bedroom1\_3, Bedroom2\_1, Bedroom2\_2 ... and so on.
  
  The gradient boosting algorithms are very good at working with missing values. So probably lightgbm and xgboost as last layers could give good results.
  
  So in the end you can check all the variants and even do ensembles from the variants that give the best results.
  
  > **Comments:**
  > **username_3**: option 2,3, and 4 is overkilling, you have useless datas (blank/black images) !  
  > **username_2**: According to my experience, boosting algorithms, like lightgbm and xgboost, significantly increase performance if you use rows with missing values instead of just removing them. Missing value is also an information. If there are not all photos of all rooms then I would suggest that the seller is hiding something. And the price should go down because the missing room could be in awful conditions.  
  > **username_0**: Maybe, but I'm not sure I like the blank images either in option 4, for example, say that the kitchen is gorgeous, but your algorithm punishes a single picture of the kitchen because of the blank 5 slots for kitchen pictures.  
  > **username_0**: I am also concerned about option 1. I like that it deals with a test set observation that can have more than the max number of images in the training set, which is a real concern, but I do worry that averaging would wash out a picture that could severely move price in one direction or the other.  
  > **username_2**: Blank does not mean punishment. It is for the algorithm to decide which empty picture to punish. Or it can learn to just use one picture that is present. If in your dataset one picture of a gorgeous kitchen has a high price then the algorithm will learn that one picture is enough.  
  
  ---
  
  