<jupyter_start><jupyter_text><jupyter_code>import math
from math import log

def cross_entropy(input_data):
  loss=0
  n=len(input_data)
  for entry in input_data:
    w_sum =entry[0]
    y=entry[1]
    loss += -(y*math.log10(w_sum)+(1-y)*math.log10(1-w_sum))
    print(-(y*math.log10(w_sum)+(1-y)*math.log10(1-w_sum)))
  return loss/n

input_data=[(0,26,1),
            (0,20,0),
            (0,48,1),
            (0,30,0)]
            
cross_entropy(input_data)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1724137931034483, 'fraction_numerical': 0.06288032454361055, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '629493', 'license': 'MIT', 'n_tokens_mistral': 227, 'n_tokens_neox': 214, 'n_words': 27, 'path': 'cross_entropy.ipynb', 'repo_name': 'ishancoderr/GANs', 'size': '493'}