'xavier_initializer' not supported, please update TensorFlow

82 Views Asked by At

I use google-colab

My function is:


def createModelUsingTensorflow(nbClasses, imageSizeX, imageSizeY, imageSizeZ, args):
  '''Create the Deep Neural Network Model'''
  print("[+] Creating model...")
  convnet = input_data(shape=[None, imageSizeX, imageSizeY, imageSizeZ], name='input')

  convnet = conv_2d(convnet, 64, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = conv_2d(convnet, 128, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = conv_2d(convnet, 256, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = conv_2d(convnet, 512, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = conv_2d(convnet, 1024, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = conv_2d(convnet, 2048, 2, activation='relu', weights_init="Xavier")
  convnet = max_pool_2d(convnet, 2)

  convnet = fully_connected(convnet, 4096, activation='relu')
  convnet = dropout(convnet, 0.5)

  convnet = fully_connected(convnet, nbClasses, activation='softmax')
  convnet = regression(convnet, optimizer='adam', loss='categorical_crossentropy', learning_rate=learningRate)

  # model = tflearn.DNN(convnet, tensorboard_dir='tensorboard', tensorboard_verbose=3)
  createFolder(checkpointPath)
  model = tflearn.DNN(convnet, checkpoint_path='{}/model.tfl'.format(checkpointPath), max_checkpoints=1)

  if args.resume and args.epochs:
    try:
      model.load('{}/model.tfl-{}'.format(checkpointPath, args.resume))
      print("    Model retrieved and resuming training!")
    except Exception as err:
      print("Couldn't load the previous model", err)
      raise err
  else:
    print("    Model created!")
  return model

I get an error when I call the function

My error is: enter image description here because the version of the TensorFlow

What can I do ? or How do I use Glorot in my function?

thanks!!

1

There are 1 best solutions below

0
On

From the image you shared, it seems you are using tflearn library instead of Tensorflow or Keras. In that case, you will have to pass tflearn.initializations.xavier() method to weights_init= in your conv_2d call. The method signature for tflearn.initializations.xavier() is:

tflearn.initializations.xavier (uniform=True, seed=None, dtype=tf.float32)

Hope that works!

P.S: A small suggestion, always share your relevant import statements or proper library name and version for people to help you better and quicker