
'''simple docstring'''
import numpy






class 	snake_case__       :







		"""simple docstring"""

		def __init__(      self				:			Any  ,	UpperCamelCase__				:			numpy.ndarray  ,	UpperCamelCase__				:			numpy.ndarray      )						->			None:






				"""simple docstring"""







				snake_case  :       Optional[Any]     			=						input_array

				# Random initial weights are assigned where first argument is the
				# number of nodes in previous layer and second argument is the
				# number of nodes in the next layer.

				# Random initial weights are assigned.
				# self.input_array.shape[1] is used to represent number of nodes in input layer.
				# First hidden layer consists of 4 nodes.
				snake_case  :       List[str]     			=						numpy.random.rand(
				    self.input_array.shape[1]  ,	4      )

				# Random initial values for the first hidden layer.
				# First hidden layer has 4 nodes.
				# Second hidden layer has 3 nodes.
				snake_case  :       Union[str, Any]     			=						numpy.random.rand(
				    4  ,	3      )

				# Random initial values for the second hidden layer.
				# Second hidden layer has 3 nodes.
				# Output layer has 1 node.
				snake_case  :       int     			=						numpy.random.rand(3  ,	1      )

				# Real output values provided.
				snake_case  :       Dict     			=						output_array

				# Predicted output values by the neural network.
				# Predicted_output array initially consists of zeroes.
				snake_case  :       List[Any]     			=						numpy.zeros(output_array.shape      )



		def       lowerCAmelCase				(      self				:			Any      )						->			numpy.ndarray:






				"""simple docstring"""







				snake_case  :       Union[str, Any]     			=						sigmoid(
				    numpy.dot(self.input_array  ,	self.input_layer_and_first_hidden_layer_weights      )      )

				# layer_between_first_hidden_layer_and_second_hidden_layer is the layer
				# connecting the first hidden set of nodes with the second hidden set of nodes.
				snake_case  :       Any     			=						sigmoid(
				    numpy.dot(
				        self.layer_between_input_and_first_hidden_layer  ,	self.first_hidden_layer_and_second_hidden_layer_weights  ,	)      )

				# layer_between_second_hidden_layer_and_output is the layer connecting
				# second hidden layer with the output node.
				snake_case  :       Optional[Any]     			=						sigmoid(
				    numpy.dot(
				        self.layer_between_first_hidden_layer_and_second_hidden_layer  ,	self.second_hidden_layer_and_output_layer_weights  ,	)      )

				return self.layer_between_second_hidden_layer_and_output



		def       lowerCAmelCase				(      self				:			Dict      )						->			None:






				"""simple docstring"""







				snake_case  :       Dict     			=						numpy.dot(
				    self.layer_between_first_hidden_layer_and_second_hidden_layer.T  ,	2
				    * (self.output_array - self.predicted_output)
				    * sigmoid_derivative(self.predicted_output      )  ,	)
				snake_case  :       str     			=						numpy.dot(
				    self.layer_between_input_and_first_hidden_layer.T  ,	numpy.dot(
				        2
				        * (self.output_array - self.predicted_output)
				        * sigmoid_derivative(self.predicted_output      )  ,	self.second_hidden_layer_and_output_layer_weights.T  ,	)
				    * sigmoid_derivative(
				        self.layer_between_first_hidden_layer_and_second_hidden_layer      )  ,	)
				snake_case  :       Optional[int]     			=						numpy.dot(
				    self.input_array.T  ,	numpy.dot(
				        numpy.dot(
				            2
				            * (self.output_array - self.predicted_output)
				            * sigmoid_derivative(self.predicted_output      )  ,	self.second_hidden_layer_and_output_layer_weights.T  ,	)
				        * sigmoid_derivative(
				            self.layer_between_first_hidden_layer_and_second_hidden_layer      )  ,	self.first_hidden_layer_and_second_hidden_layer_weights.T  ,	)
				    * sigmoid_derivative(self.layer_between_input_and_first_hidden_layer      )  ,	)

				self.input_layer_and_first_hidden_layer_weights += (
				    updated_input_layer_and_first_hidden_layer_weights
				)
				self.first_hidden_layer_and_second_hidden_layer_weights += (
				    updated_first_hidden_layer_and_second_hidden_layer_weights
				)
				self.second_hidden_layer_and_output_layer_weights += (
				    updated_second_hidden_layer_and_output_layer_weights
				)



		def       lowerCAmelCase				(      self				:			Any  ,	UpperCamelCase__				:			numpy.ndarray  ,	UpperCamelCase__				:			int  ,	UpperCamelCase__				:			bool      )						->			None:






				"""simple docstring"""







				for iteration in range(1  ,	iterations + 1      ):
						snake_case  :       Optional[Any]     			=						self.feedforward()
						self.back_propagation()
						if give_loss:
								snake_case  :       str     			=						numpy.mean(numpy.square(output - self.feedforward()      )      )
								print(f'Iteration {iteration} Loss: {loss}'      )



		def       lowerCAmelCase				(      self				:			Any  ,	UpperCamelCase__				:			numpy.ndarray      )						->			int:






				"""simple docstring"""







				snake_case  :       List[str]     			=						input_arr

				snake_case  :       Union[str, Any]     			=						sigmoid(
				    numpy.dot(self.array  ,	self.input_layer_and_first_hidden_layer_weights      )      )

				snake_case  :       Optional[int]     			=						sigmoid(
				    numpy.dot(
				        self.layer_between_input_and_first_hidden_layer  ,	self.first_hidden_layer_and_second_hidden_layer_weights  ,	)      )

				snake_case  :       Union[str, Any]     			=						sigmoid(
				    numpy.dot(
				        self.layer_between_first_hidden_layer_and_second_hidden_layer  ,	self.second_hidden_layer_and_output_layer_weights  ,	)      )

				return int(self.layer_between_second_hidden_layer_and_output > 0.6      )







def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__			)  ->							numpy.ndarray:


		'''simple docstring'''


		return 1 / (1 + numpy.exp(-value			))




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__			)  ->							numpy.ndarray:


		'''simple docstring'''


		return (value) * (1 - (value))




def    _UpperCamelCase						(       )  ->							int:


		'''simple docstring'''


		snake_case  :       Tuple     			=						numpy.array(
		    (
		        [0, 0, 0],
		        [0, 0, 1],
		        [0, 1, 0],
		        [0, 1, 1],
		        [1, 0, 0],
		        [1, 0, 1],
		        [1, 1, 0],
		        [1, 1, 1],
		    ) ,       dtype=numpy.floataa ,       )

		# True output values for the given input values.
		snake_case  :       int     			=						numpy.array(([0], [1], [1], [0], [1], [0], [0], [1]) ,       dtype=numpy.floataa			)

		# Calling neural network class.
		snake_case  :       Union[str, Any]     			=						TwoHiddenLayerNeuralNetwork(
		    input_array=SCREAMING_SNAKE_CASE__ ,       output_array=SCREAMING_SNAKE_CASE__			)

		# Calling training function.
		# Set give_loss to True if you want to see loss in every iteration.
		neural_network.train(output=SCREAMING_SNAKE_CASE__ ,       iterations=10 ,       give_loss=SCREAMING_SNAKE_CASE__			)

		return neural_network.predict(numpy.array(([1, 1, 1]) ,       dtype=numpy.floataa			)			)


if __name__ == "__main__":
						example()




'''simple docstring'''
import os
from collections.abc import Iterator




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ = "."			)  ->							Iterator[str]:


		'''simple docstring'''


		for dir_path, dir_names, filenames in os.walk(SCREAMING_SNAKE_CASE__			):
				snake_case  :       Optional[Any]     			=						[d for d in dir_names if d != '''scripts''' and d[0] not in '''._''']
				for filename in filenames:
						if filename == "__init__.py":
								continue
						if os.path.splitext(SCREAMING_SNAKE_CASE__			)[1] in (".py", ".ipynb"):
								yield os.path.join(SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__			).lstrip('''./'''			)




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__			)  ->							List[str]:


		'''simple docstring'''


		return F'{i * "  "}*' if i else "\n##"




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__			)  ->							str:


		'''simple docstring'''


		snake_case  :       Union[str, Any]     			=						old_path.split(os.sep			)
		for i, new_part in enumerate(new_path.split(os.sep			)			):
				if (i + 1 > len(SCREAMING_SNAKE_CASE__			) or old_parts[i] != new_part) and new_part:
						print(F'{md_prefix(SCREAMING_SNAKE_CASE__			)} {new_part.replace("_" ,       " "			).title()}'			)
		return new_path




def    _UpperCamelCase						(       SCREAMING_SNAKE_CASE__ = "."			)  ->							None:


		'''simple docstring'''


		snake_case  :       List[Any]     			=						''''''
		for filepath in sorted(good_file_paths(SCREAMING_SNAKE_CASE__			)			):
				snake_case			,snake_case  :       Optional[Any]     			=						os.path.split(SCREAMING_SNAKE_CASE__			)
				if filepath != old_path:
						snake_case  :       Dict     			=						print_path(SCREAMING_SNAKE_CASE__ ,       SCREAMING_SNAKE_CASE__			)
				snake_case  :       int     			=						(filepath.count(os.sep			) + 1) if filepath else 0
				snake_case  :       int     			=						F'{filepath}/{filename}'.replace(''' ''' ,       '''%20'''			)
				snake_case  :       int     			=						os.path.splitext(filename.replace('''_''' ,       ''' '''			).title()			)[0]
				print(F'{md_prefix(SCREAMING_SNAKE_CASE__			)} [{filename}]({url})'			)


if __name__ == "__main__":
						print_directory_md(".")


