





'''simple docstring'''







import numpy
class 			_lowercase						:







     def __init__( self    ,   A__    ,   A__    ) ->	None:
      snake_case				=			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				=			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				=			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				=			numpy.random.rand(3    ,   1    )

      # Real output values provided.
      snake_case				=			output_array

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







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







     def     UpperCamelCase			( self    ,   A__    ) ->	int:
      snake_case				=			input_arr

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

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

      snake_case				=			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	(	a    : numpy.ndarray     ) ->numpy.ndarray:
 return 1 / (1 + numpy.exp(-value     ))

def    __UpperCamelCase	(	a    : numpy.ndarray     ) ->numpy.ndarray:
 return (value) * (1 - (value))

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

 # Calling neural network class.
 snake_case				=			TwoHiddenLayerNeuralNetwork(
     input_array=a					,   output_array=a     )

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

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


if __name__ == "__main__":
   example()








'''simple docstring'''







import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text

def    __UpperCamelCase	(	a    : List[str]     ) ->str:
 snake_case				=			[]
 for line in lines:
  snake_case				=			re.sub(R'''#.*'''					,   ''''''					,   a     )  # remove comments
  if line:
   filtered_lines.append(a     )
 snake_case				=			'''\n'''.join(a     )

 # Make a hash from all this code
 snake_case				=			full_str.encode('''utf-8'''     )
 return shaaaa(a     ).hexdigest()


# get importable module names and hash for caching
_lowercase       						=			{
    'csv': (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    'json': (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    'pandas': (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    'parquet': (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    'arrow': (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    'text': (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    'imagefolder': (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    'audiofolder': (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
_lowercase       						=			{
    '.csv': ('csv', {}),
    '.tsv': ('csv', {'sep': '\t'}),
    '.json': ('json', {}),
    '.jsonl': ('json', {}),
    '.parquet': ('parquet', {}),
    '.arrow': ('arrow', {}),
    '.txt': ('text', {}),
}
_EXTENSION_TO_MODULE.update({ext: ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_lowercase       						=			{'imagefolder', 'audiofolder'}

# Used to filter data files based on extensions given a module name
_lowercase       						=			{}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
   _MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append('.zip')






_MODULE_TO_EXTENSIONS["audiofolder"].append('.zip')

