Tuesday 31 October 2017

Keras version error - how to know the version of keras - how to solve

model.add(LSTM(HIDDEN_LAYER_SIZE, dropout=0.2, recurrent_dropout=0.2))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/models.py", line 475, in add
    output_tensor = layer(self.outputs[0])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/layers/recurrent.py", line 268, in __call__
    return super(Recurrent, self).__call__(inputs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/topology.py", line 575, in __call__
    self.build(input_shapes[0])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/layers/recurrent.py", line 1050, in build
    constraint=self.bias_constraint)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/engine/topology.py", line 396, in add_weight
    weight = K.variable(initializer(shape),
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/layers/recurrent.py", line 1042, in bias_initializer
    self.bias_initializer((self.units * 2,), *args, **kwargs),
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 1709, in concatenate
    return tf.concat([to_dense(x) for x in tensors],axis)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1075, in concat
    Returns:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 165, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.





python3 -c 'import keras; print(keras.__version__)'


I only take tensorflow_backend.py in concatenate(tensors, axis)
Change this:
return tf.concat([to_dense(x) for x in tensors], axis)  
To this:
return tf.concat(axis,[to_dense(x) for x in tensors])

How to update tensorflo to a specific version or the latest

Specific Version
pip3 install 'tensorflow==1.0.0' --force-reinstall

Latest version
pip3 install tensorflow --upgrade 

Thursday 26 October 2017

./configure cudnn and cuda sdk

Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0

Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /Developer/NVIDIA/CUDA-8.0/

Please specify the cuDNN version you want to use. [Leave empty to use system default]: 7
Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /Developer/NVIDIA/CUDA-8.0/]: /Users/zuni/cuda/lib
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size.

[Default is: "3.5,5.2"]: 5.0

how to check your added paths in mac


cat ~/.bash_profile

output:

# added by Miniconda2 4.3.21 instal/bin:$PATH"
export PATH=“/usr/local/bin:$PATH”/
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH

# added by Miniconda2 4.3.21 installer
export PATH="/Users/zuni/miniconda2/bin:$PATH"
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH

Wednesday 18 October 2017

how to start tensorboard

$pip install tensorflow-tensorboard

$which tensorboard

#if it shows then it is installed

$tensorboard --logdir '<location of your graph file till the folder not the file name>'

open http://localhost:6006/ on a web browser




how to make python3 default

alias python=python3
source ~/.bashrc
python --version

how to know the version of tensorflow - Mac - terminal

Type the below command in terminal

python3 -c 'import tensorflow as tf; print(tf.__version__)'