{
  "id": 361810,
  "title": "Tensorflow/Keras",
  "url": "/competitions/tabular-playground-series-oct-2022/discussion/361810",
  "author_name": "graham broughton",
  "post_date": "2022-10-23T21:39:25.020000",
  "votes": 1,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hello!<br>\nI've been stumped trying to figure out how to reverse the sign of specific tensors in a dataset for tensorflow/keras. What i have been trying to do is essentially move the augmentation operations from <a href=\"https://www.kaggle.com/code/fabianbong/tps-october-2022-keras-tf-neural-network/notebook\" target=\"_blank\">this notebook</a> into conditional tensor mapping operations as the model was quite input bound. Specifically, the problem I'm having is dealing with the unknown dimension when the dataset is batched when using tf.tensor_scatter_nd_update.<br>\nHere is what I have so far, any help would be greatly appreciated!</p>\n<p><code>\npositions=X[:,:54]\nmask=tf.ones_like(positions, dtype=tf.float16)\nmask=tf.tensor_scatter_nd_update(positions, [[0],[3],[6],[9],[14],[17],[22],[25],[30],[33],[38],[41],[46],[49]], [-1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\nmask=tf.expand_dims(mask, axis=-1)\nnew_pos=mask * positions\n</code><br>\n*Edit: Sorry I don't know why the code block is printing like that :S</p>",
  "messages": [
    {
      "id": 2001272,
      "postDate": "2022-10-23T21:39:25.020Z",
      "content": "<p>Hello!<br>\nI've been stumped trying to figure out how to reverse the sign of specific tensors in a dataset for tensorflow/keras. What i have been trying to do is essentially move the augmentation operations from <a href=\"https://www.kaggle.com/code/fabianbong/tps-october-2022-keras-tf-neural-network/notebook\" target=\"_blank\">this notebook</a> into conditional tensor mapping operations as the model was quite input bound. Specifically, the problem I'm having is dealing with the unknown dimension when the dataset is batched when using tf.tensor_scatter_nd_update.<br>\nHere is what I have so far, any help would be greatly appreciated!</p>\n<p><code>\npositions=X[:,:54]\nmask=tf.ones_like(positions, dtype=tf.float16)\nmask=tf.tensor_scatter_nd_update(positions, [[0],[3],[6],[9],[14],[17],[22],[25],[30],[33],[38],[41],[46],[49]], [-1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\nmask=tf.expand_dims(mask, axis=-1)\nnew_pos=mask * positions\n</code><br>\n*Edit: Sorry I don't know why the code block is printing like that :S</p>",
      "rawMarkdown": "Hello!\nI've been stumped trying to figure out how to reverse the sign of specific tensors in a dataset for tensorflow/keras. What i have been trying to do is essentially move the augmentation operations from [this notebook](https://www.kaggle.com/code/fabianbong/tps-october-2022-keras-tf-neural-network/notebook) into conditional tensor mapping operations as the model was quite input bound. Specifically, the problem I'm having is dealing with the unknown dimension when the dataset is batched when using tf.tensor_scatter_nd_update.\nHere is what I have so far, any help would be greatly appreciated!\n\n`\npositions=X[:,:54]\nmask=tf.ones_like(positions, dtype=tf.float16)\nmask=tf.tensor_scatter_nd_update(positions, [[0],[3],[6],[9],[14],[17],[22],[25],[30],[33],[38],[41],[46],[49]], [-1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\nmask=tf.expand_dims(mask, axis=-1)\nnew_pos=mask * positions\n`\n*Edit: Sorry I don't know why the code block is printing like that :S",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2001272": "Hello!\nI've been stumped trying to figure out how to reverse the sign of specific tensors in a dataset for tensorflow/keras. What i have been trying to do is essentially move the augmentation operations from [this notebook](https://www.kaggle.com/code/fabianbong/tps-october-2022-keras-tf-neural-network/notebook) into conditional tensor mapping operations as the model was quite input bound. Specifically, the problem I'm having is dealing with the unknown dimension when the dataset is batched when using tf.tensor_scatter_nd_update.\nHere is what I have so far, any help would be greatly appreciated!\n\n`\npositions=X[:,:54]\nmask=tf.ones_like(positions, dtype=tf.float16)\nmask=tf.tensor_scatter_nd_update(positions, [[0],[3],[6],[9],[14],[17],[22],[25],[30],[33],[38],[41],[46],[49]], [-1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1])\nmask=tf.expand_dims(mask, axis=-1)\nnew_pos=mask * positions\n`\n*Edit: Sorry I don't know why the code block is printing like that :S"
  }
}