# Path: util/RBM/util.py
# def tf_xavier_init(fan_in, fan_out, const=1.0, dtype=np.float32):
#     k = const * np.sqrt(6.0 / (fan_in + fan_out))
#     return tf.random_uniform((fan_in, fan_out), minval=-k, maxval=k, dtype=dtype)


import tensorflow as tf
import numpy as np
import time 
from tqdm import tqdm
from util.RBM.util import tf_xavier_init
		for i in range(len(self.encoding_layer_sizes)):
			input_dim = int(next_layer_input.get_shape()[1])
			layer_dim = self.encoding_layer_sizes[i]

			# Initialize W using xavier initialization
			W = tf.Variable(tf_xavier_init(input_dim, layer_dim, const=4.0), name=layer_names[i][0])

			# Initialize b to zero
			b = tf.Variable(tf.zeros([layer_dim]), name=layer_names[i][1])

			self.encoding_weights.append(W)
			self.encoding_biases.append(b)

			# Output of this layer becomes next layer's input
			next_layer_input = tf.nn.sigmoid(tf.matmul(next_layer_input, W) + b)

		self.encoded_x = next_layer_input
		
		self.encoding_layer_sizes.reverse()
		self.decoding_layer_sizes = self.encoding_layer_sizes[1:] + [input_size]
		self.encoding_layer_sizes.reverse()

		reversed_encoding_weights = self.encoding_weights[::-1] # Reversed list
		self.decoding_weights = []
		self.decoding_biases = []

		for i in range(len(self.decoding_layer_sizes)):
			input_dim = int(next_layer_input.get_shape()[1])
			layer_dim = self.decoding_layer_sizes[i]


# Path: util/RBM/util.py
# def tf_xavier_init(fan_in, fan_out, const=1.0, dtype=np.float32):
#     k = const * np.sqrt(6.0 / (fan_in + fan_out))
#     return tf.random_uniform((fan_in, fan_out), minval=-k, maxval=k, dtype=dtype)


# Path: util/autoencoder.py
import tensorflow as tf
import numpy as np
import time 
from tqdm import tqdm
from util.RBM.util import tf_xavier_init

		for i in range(len(self.encoding_layer_sizes)):
			input_dim = int(next_layer_input.get_shape()[1])
			layer_dim = self.encoding_layer_sizes[i]

			# Initialize W using xavier initialization
			W = tf.Variable(tf_xavier_init(input_dim, layer_dim, const=4.0), name=layer_names[i][0])

			# Initialize b to zero
			b = tf.Variable(tf.zeros([layer_dim]), name=layer_names[i][1])

			self.encoding_weights.append(W)
			self.encoding_biases.append(b)

			# Output of this layer becomes next layer's input
			next_layer_input = tf.nn.sigmoid(tf.matmul(next_layer_input, W) + b)

		self.encoded_x = next_layer_input
		
		self.encoding_layer_sizes.reverse()
		self.decoding_layer_sizes = self.encoding_layer_sizes[1:] + [input_size]
		self.encoding_layer_sizes.reverse()

		reversed_encoding_weights = self.encoding_weights[::-1] # Reversed list
		self.decoding_weights = []
		self.decoding_biases = []

		for i in range(len(self.decoding_layer_sizes)):
			input_dim = int(next_layer_input.get_shape()[1])
			layer_dim = self.decoding_layer_sizes[i]


			W = tf.Variable(tf_xavier_init(input_dim, layer_dim, const=4.0), name=layer_names[i][0]+'_d')