<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <a href="https
Step1:  Reading in data sets
Step2:  Layers
Step3:  Feature columns
transform a diverse range of raw data into formats input layers can accept
https
<ASSISTANT_TASK:>
Python Code:
# import and check version
import tensorflow as tf
# tf can be really verbose
tf.logging.set_verbosity(tf.logging.ERROR)
print(tf.__version__)
# a small sanity check, does tf seem to work ok? 
hello = tf.constant('Hello TF!')
sess = tf.Session()
print(sess.run(hello))
sess.close()
Explanation: <a href="https://colab.research.google.com/github/DJCordhose/ai/blob/master/notebooks/tensorflow/tf_low_level_advanced.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
Low Level TensorFlow, Part II: Advanced
https://www.tensorflow.org/guide/low_level_intro
End of explanation
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
z = x + y
r = tf.random_normal([10, 2])
dataset = tf.data.Dataset.from_tensor_slices(r)
iterator = dataset.make_initializable_iterator()
next_row = iterator.get_next()
with tf.Session() as sess:
  sess.run(iterator.initializer)
  while True:
    try:
      data = sess.run(next_row)
      print(data)
      print(sess.run(z, feed_dict={x: data[0], y: data[1]}))
    except tf.errors.OutOfRangeError:
      break
Explanation: Reading in data sets
End of explanation
x = tf.placeholder(tf.float32, shape=[None, 3])
y = tf.layers.dense(inputs=x, units=1)
with tf.Session() as sess:
  try:
    print(sess.run(y, {x: [[1, 2, 3], [4, 5, 6]]}))
  except tf.errors.FailedPreconditionError as fpe:
    print(fpe.message)
with tf.Session() as sess:
  sess.run(tf.global_variables_initializer())
  print(sess.run(y, {x: [[1, 2, 3], [4, 5, 6]]}))
y = tf.layers.dense(inputs=x, units=2, activation=tf.nn.tanh)
with tf.Session() as sess:
  sess.run(tf.global_variables_initializer())
  print(sess.run(y, {x: [[1, 2, 3], [4, 5, 6]]}))
Explanation: Layers
End of explanation
features = {
    'sales' : [[5], [10], [8], [9]],
    'department': ['sports', 'sports', 'gardening', 'gardening']
}
# numeric values are simple
sales_column = tf.feature_column.numeric_column('sales')
columns = {
   sales_column
}
inputs = tf.feature_column.input_layer(features, columns)
# categories are harders, as NNs only accept dense numeric values
categorical_department_column = tf.feature_column.categorical_column_with_vocabulary_list(
        'department', ['sports', 'gardening'])
columns = {
  sales_column,
  categorical_department_column
}
# we can decide if we want the category to be encoded as embedding or multi-hot 
try:
  inputs = tf.feature_column.input_layer(features, columns)
except ValueError as ve:
  print(ve)
multi_hot_department_column = tf.feature_column.indicator_column(categorical_department_column)
columns = {
  sales_column,
  multi_hot_department_column
}
inputs = tf.feature_column.input_layer(features, columns)
# feature columns also need initialization
var_init = tf.global_variables_initializer()
table_init = tf.tables_initializer()
with tf.Session() as sess:
  sess.run((var_init, table_init))
  # first two are departments last entry is just sales as is
  print(sess.run(inputs))
# multi (one in our case) hot encoding of departments
columns = {
  multi_hot_department_column
}
inputs = tf.feature_column.input_layer(features, columns)
var_init = tf.global_variables_initializer()
table_init = tf.tables_initializer()
with tf.Session() as sess:
  sess.run((var_init, table_init))
  print(sess.run(inputs))
# alternative, embedding in three dimensions
embedding_department_column = tf.feature_column.embedding_column(categorical_department_column, dimension=3)
columns = {
  embedding_department_column
}
inputs = tf.feature_column.input_layer(features, columns)
var_init = tf.global_variables_initializer()
table_init = tf.tables_initializer()
with tf.Session() as sess:
  sess.run((var_init, table_init))
  print(sess.run(inputs))
Explanation: Feature columns
transform a diverse range of raw data into formats input layers can accept
https://www.tensorflow.org/guide/feature_columns
https://www.tensorflow.org/api_docs/python/tf/feature_column/input_layer
End of explanation
<END_TASK>