<commit_before># -*- coding:utf8 -*-
# File   : node.py
# Author : <NAME>
# Email  : <EMAIL>
# Date   : 12/31/16
# 
# This file is part of TensorArtist

from ...core.utils.meta import assert_instance, assert_notnone, AttrObject

import numpy as np
import tensorflow as tf

__all__ = [
    '__valid_tensor_types__', '__valid_tf_tensor_types__',
    'VarNode', 'OprNode', 'as_varnode', 'as_tftensor'
]


class VarNodeStore(object):
    def __init__(self):
        self.__kv = {}

    def get(self, tensor):
        if tensor in self.__kv:
            return self.__kv[tensor]
        v = self._make(tensor)
        self.__kv[tensor] = v
        return v

    def _make(self, tensor):
        return VarNode(tensor)

varnode_store = VarNodeStore()


class VarNodeOpDecl(object):
    def __binary(self, rhs, op_name):
        rhs = as_varnode(rhs)
        return as_varnode(getattr(tf, op_name)(self, rhs))

    def __rbinary(self, lhs, op_name):
        lhs = as_varnode(lhs)
        return as_varnode(getattr(tf, op_name)(lhs, self))<commit_msg>[dev-mjy] automatically convert int to float for varnode operation<commit_after># -*- coding:utf8 -*-
# File   : node.py
# Author : <NAME>
# Email  : <EMAIL>
# Date   : 12/31/16
# 
# This file is part of TensorArtist

from ...core.utils.meta import assert_instance, assert_notnone, AttrObject

import numpy as np
import tensorflow as tf

__all__ = [
    '__valid_tensor_types__', '__valid_tf_tensor_types__',
    'VarNode', 'OprNode', 'as_varnode', 'as_tftensor'
]


class VarNodeStore(object):
    def __init__(self):
        self.__kv = {}

    def get(self, tensor):
        if tensor in self.__kv:
            return self.__kv[tensor]
        v = self._make(tensor)
        self.__kv[tensor] = v
        return v

    def _make(self, tensor):
        return VarNode(tensor)

varnode_store = VarNodeStore()


class VarNodeOpDecl(object):
    def __binary(self, rhs, op_name):
        if (self.dtype == 'float32' or self.dtype == 'float64') and type(rhs) is int:
            rhs = float(rhs)
        rhs = as_varnode(rhs)
        return as_varnode(getattr(tf, op_name)(self, rhs))

    def __rbinary(self, lhs, op_name):
        if (self.dtype == 'float32' or self.dtype == 'float64') and type(lhs) is int:
            lhs = float(lhs)
        lhs = as_varnode(lhs)
        return as_varnode(getattr(tf, op_name)(lhs, self))
{'fraction_non_alphanumeric': 0.12283663993246095, 'fraction_numerical': 0.009286618826509076, 'mean_word_length': 2.910891089108911, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1747143', 'n_tokens_mistral': 839, 'n_tokens_neox': 825, 'n_words': 203}