






import numpy


class     _a							:






  """simple docstring"""





  def __init__(  self		,		_UpperCAmelCase		,		_UpperCAmelCase			)      ->			None:
     UpperCamelCase_						=  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.
     UpperCamelCase_						=  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.
     UpperCamelCase_						=  numpy.random.rand(
         4		,		3			)

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

     # Real output values provided.
     UpperCamelCase_						=  output_array

     # Predicted output values by the neural network.
     # Predicted_output array initially consists of zeroes.
     UpperCamelCase_						=  numpy.zeros(output_array.shape			)




  def  _UpperCAmelCase  (  self			)      ->			numpy.ndarray:
     UpperCamelCase_						=  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.
     UpperCamelCase_						=  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.
     UpperCamelCase_						=  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  _UpperCAmelCase  (  self			)      ->			None:
     UpperCamelCase_						=  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			)		,		)
     UpperCamelCase_						=  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			)		,		)
     UpperCamelCase_						=  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  _UpperCAmelCase  (  self		,		_UpperCAmelCase		,		_UpperCAmelCase		,		_UpperCAmelCase			)      ->			None:
     for iteration in range(1		,		iterations + 1			):
        UpperCamelCase_						=  self.feedforward()
        self.back_propagation()
        if give_loss:
           UpperCamelCase_						=  numpy.mean(numpy.square(output - self.feedforward()			)			)
           print(f"""Iteration {iteration} Loss: {loss}"""			)




  def  _UpperCAmelCase  (  self		,		_UpperCAmelCase			)      ->			int:
     UpperCamelCase_						=  input_arr

     UpperCamelCase_						=  sigmoid(
         numpy.dot(self.array		,		self.input_layer_and_first_hidden_layer_weights			)			)

     UpperCamelCase_						=  sigmoid(
         numpy.dot(
             self.layer_between_input_and_first_hidden_layer		,		self.first_hidden_layer_and_second_hidden_layer_weights		,		)			)

     UpperCamelCase_						=  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      _snake_case     (__lowercase):
   return 1 / (1 + numpy.exp(-value))






def      _snake_case     (__lowercase):
   return (value) * (1 - (value))






def      _snake_case     ():
   UpperCamelCase_						=  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.
   UpperCamelCase_						=  numpy.array(([0], [1], [1], [0], [1], [0], [0], [1])     ,   dtype=numpy.floataa)

   # Calling neural network class.
   UpperCamelCase_						=  TwoHiddenLayerNeuralNetwork(
       input_array=__lowercase     ,   output_array=__lowercase)

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

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


if __name__ == "__main__":
 example()











'''simple docstring'''


import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict
@pytest.mark.parametrize(
    '''split_dict'''					,		[
        SplitDict(),
        SplitDict({'''train''': SplitInfo(name='''train'''					,		num_bytes=1337					,		num_examples=42					,		dataset_name='''my_dataset''' )} ),
        SplitDict({'''train''': SplitInfo(name='''train'''					,		num_bytes=1337					,		num_examples=42 )} ),
        SplitDict({'''train''': SplitInfo()} ),
    ]					,		)
def 						snake_case_       (UpperCamelCase			:    SplitDict ):





							'''simple docstring'''


							_a      	=							split_dict._to_yaml_list()
							assert len(UpperCamelCase ) == len(UpperCamelCase )
							_a      	=							SplitDict._from_yaml_list(UpperCamelCase )
							for split_name, split_info in split_dict.items():
														# dataset_name field is deprecated, and is therefore not part of the YAML dump
														_a      	=							None
														# the split name of split_dict takes over the name of the split info object
														_a      	=							split_name
							assert split_dict == reloaded

@pytest.mark.parametrize(
    '''split_info'''					,		[SplitInfo(), SplitInfo(dataset_name=UpperCamelCase ), SplitInfo(dataset_name='''my_dataset''' )] )
def 						snake_case_       (UpperCamelCase			:    List[str] ):





							'''simple docstring'''


							_a      	=							asdict(SplitDict({'''train''': split_info} ) )
							assert "dataset_name" in split_dict_asdict["train"]
							assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name

