def GetBytes(mem_str):
  """Converts human-readable numbers to bytes.

  E.g., converts '2.1M' to 2.1 * 1024 * 1024 bytes.
  """
  unit = mem_str[-1]
  val = float(mem_str[:-1])
  if unit == 'G':
    val *= 1024*1024*1024
  elif unit == 'M':
    val *= 1024*1024
  elif unit == 'K':
    val *= 1024
  else:
    try:
      val = int(mem_str)
    except Exception:
      print '%s is not a valid way of writing memory size.' % mem_str
  return int(val)
Converts human-readable numbers to bytes.

  E.g., converts '2.1M' to 2.1 * 1024 * 1024 bytes.
  
deepnet/datahandler.py