<commit_before>// Cos neuron activation function layer.
// Adapted from TanH layer code

#include <vector>

#include "caffe/layers/trig_layer.hpp"

namespace caffe {

template <typename Dtype>
void TrigLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
      const vector<Blob<Dtype>*>& top) {
  func = this->layer_param_.trig_param().function();
}

template <typename Dtype>
void TrigLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
    const vector<Blob<Dtype>*>& top) {
  const Dtype* bottom_data = bottom[0]->cpu_data();
  Dtype* top_data = top[0]->mutable_cpu_data();
  const int count = bottom[0]->count();
  for (int i = 0; i < count; ++i) {
    if(func == TrigParameter_Function_COS)
      top_data[i] = cos(bottom_data[i]);
    else if(func == TrigParameter_Function_SIN)
      top_data[i] = cos(bottom_data[i]);
    else
      CHECK(0) << "Unsupported trig function";
  }
}

template <typename Dtype>
void TrigLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
    const vector<bool>& propagate_down,
    const vector<Blob<Dtype>*>& bottom) {
  if (propagate_down[0]) {<commit_msg>Fix CPU sin Trig layer to actually compute sin<commit_after>// Cos neuron activation function layer.
// Adapted from TanH layer code

#include <vector>

#include "caffe/layers/trig_layer.hpp"

namespace caffe {

template <typename Dtype>
void TrigLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
      const vector<Blob<Dtype>*>& top) {
  func = this->layer_param_.trig_param().function();
}

template <typename Dtype>
void TrigLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
    const vector<Blob<Dtype>*>& top) {
  const Dtype* bottom_data = bottom[0]->cpu_data();
  Dtype* top_data = top[0]->mutable_cpu_data();
  const int count = bottom[0]->count();
  for (int i = 0; i < count; ++i) {
    if(func == TrigParameter_Function_COS)
      top_data[i] = cos(bottom_data[i]);
    else if(func == TrigParameter_Function_SIN)
      top_data[i] = sin(bottom_data[i]);
    else
      CHECK(0) << "Unsupported trig function";
  }
}

template <typename Dtype>
void TrigLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
    const vector<bool>& propagate_down,
    const vector<Blob<Dtype>*>& bottom) {
  if (propagate_down[0]) {
{'fraction_non_alphanumeric': 0.1509433962264151, 'fraction_numerical': 0.005265467310223783, 'mean_word_length': 4.922077922077922, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, '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}}
{'dir': 'git-commits-cleaned', 'id': '113497', 'n_tokens_mistral': 808, 'n_tokens_neox': 793, 'n_words': 180}