o
    ?eH                  %   @   s  d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZm Z  ej!ej"edgdedd@dej#ej$ dej#ej% fddZ&ede'e&Z(e&j)j*Z+dej#ej$ dej#ej% fddZ,e-dg dZ.ej!ej"edgdeddAde ej#ej%  de ej#ej%  de ej#ej/  d e ej#ej/  d!ej#ej/ d"ej#ej/ d#e ej#ej%  d$e ej#ej/  d%e ej#ej/  d&ej#ej/ d'e0d(e1d)e1d*e2d+e2d,e3f d-d.Z4ed/e'e4Z5e4j)j*Z6de ej#ej%  de ej#ej%  de ej#ej/  d e ej#ej/  d!ej#ej/ d"ej#ej/ d#e ej#ej%  d$e ej#ej/  d%e ej#ej/  d&ej#ej/ d'e0d(e1d)e1d*e2d+e2d,e3f d0d1Z7e-d2g dZ8dAde ej#ej%  de ej#ej%  de ej#ej/  d e ej#ej/  d!ej#ej/ d"ej#ej/ d#e ej#ej%  d$e ej#ej/  d%e ej#ej/  d&ej#ej/ d'e0d(e1d)e1d*e2d+e2d3e3f d4d5Z9ed6e'e9Z:de ej#ej%  de ej#ej%  de ej#ej/  d e ej#ej/  d!ej#ej/ d"ej#ej/ d#e ej#ej%  d$e ej#ej/  d%e ej#ej/  d&ej#ej/ d'e0d(e1d)e1d*e2d+e2d3e3f d7d8Z;ej!ej"ed9gded9d@d:e ej#ej/  d(e1d)e1fd;d<Z<ed=e'e<Z=e<j)j*Z>d:e ej#ej/  d(e1d)e1fd>d?Z?dS )BzUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListztrain.sdca_fprint)v1inputreturnc                 C   s  t j pt  }|j}|jrzzt|d|| }|W S  tjy1 } zt	|| W Y d}~nd}~w tj
y:   Y nw zt| |fd}|turJ|W S t| ||dW S  tjy[   Y q ttfyy   ttdt| |d}|tjjurx| Y S  w t| |fd}|tur|S ztjd| |d\}}}}W n ttfy   ttdt| |d}|tjjur| Y S  w |dd }t rd}	|j}
td|
|	| |\}|S )zComputes fingerprints of the input strings.

  Args:
    input: A `Tensor` of type `string`.
      vector of strings to compute fingerprints on.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int64`.
  
SdcaFprintN)namectx )r   r   )_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackException_dispatcher_for_sdca_fprintNotImplementedsdca_fprint_eager_fallback_SymbolicException	TypeError
ValueError	_dispatchr   sdca_fprintdictOpDispatcherNOT_SUPPORTED_op_def_library_apply_op_helper_executemust_record_gradientinputsrecord_gradient)r   r   _ctxtld_resulte__op_outputs_attrs_inputs_flatr   r   c/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/gen_sdca_ops.pyr'      sv   r'   zraw_ops.SdcaFprintc                 C   sP   t | tj} | g}d }tjdd||||d}t r#td||| |\}|S )Ns
   SdcaFprint   r/   attrsr   r   r   )r   convert_to_tensor_dtypesstringr-   r   r.   r0   )r   r   r   r9   r8   r3   r   r   r:   r"   _   s   
r"   SdcaOptimizer)Zout_example_state_dataZout_delta_sparse_weightsZout_delta_dense_weightsztrain.sdca_optimizerTsparse_example_indicessparse_feature_indicessparse_feature_valuesdense_featuresexample_weightsexample_labelssparse_indicessparse_weightsdense_weightsexample_state_data	loss_typel1l2num_loss_partitionsnum_inner_iterations
adaptativec                 C   s  t j pt  }|j}|jrz%t|d|| |||||||||	d|
d|d|d|d|d|}t|}|W S  tj	yK } zt
|| W Y d}~nd}~w tjyT   Y nw z4t| |||||||||	|
||||||fd}|turs|W S t| |||||||||	|
|||||||d	W S  tjy   Y q ttfy   ttd
td
i d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|}|tjjur| Y S  w t| |||||||||	|
||||||fd}|tur|S t| ttfstd|  t| }t|ttfs"td| t||kr3tdt||f t|ttfsAtd| t||krRtdt||f t|ttfs`td| t||krqtdt||f t|ttfstd| t|}t|ttfstd| t|}t|ttfstd| t||krtd t||f t|
d}
t|d}t|d}t |d}t |d}|du rd!}t!|d}z@t"j#	d'i d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|\}}}}W nS ttfyr   ttd
td
i d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|}|tjjurq| Y S  w |dd }t$ rd|%dd|&dd"|'d"d#|'d#d$|'d$d|%dd|%dd|'dd|'df}|j(}t)d||| |dd% |d%d%|  g |d%| d  }|dd& |d&d g }t|}|S )(a  Distributed version of Stochastic Dual Coordinate Ascent (SDCA) optimizer for

  linear models with L1 + L2 regularization. As global optimization objective is
  strongly-convex, the optimizer optimizes the dual objective at each step. The
  optimizer applies each update one example at a time. Examples are sampled
  uniformly, and the optimizer is learning rate free and enjoys linear convergence
  rate.

  [Proximal Stochastic Dual Coordinate Ascent](http://arxiv.org/pdf/1211.2717v1.pdf).<br>
  Shai Shalev-Shwartz, Tong Zhang. 2012

  $$Loss Objective = \sum f_{i} (wx_{i}) + (l2 / 2) * |w|^2 + l1 * |w|$$

  [Adding vs. Averaging in Distributed Primal-Dual Optimization](http://arxiv.org/abs/1502.03508).<br>
  Chenxin Ma, Virginia Smith, Martin Jaggi, Michael I. Jordan,
  Peter Richtarik, Martin Takac. 2015

  [Stochastic Dual Coordinate Ascent with Adaptive Probabilities](https://arxiv.org/abs/1502.08053).<br>
  Dominik Csiba, Zheng Qu, Peter Richtarik. 2015

  Args:
    sparse_example_indices: A list of `Tensor` objects with type `int64`.
      a list of vectors which contain example indices.
    sparse_feature_indices: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `int64`.
      a list of vectors which contain feature indices.
    sparse_feature_values: A list of `Tensor` objects with type `float32`.
      a list of vectors which contains feature value
      associated with each feature group.
    dense_features: A list of `Tensor` objects with type `float32`.
      a list of matrices which contains the dense feature values.
    example_weights: A `Tensor` of type `float32`.
      a vector which contains the weight associated with each
      example.
    example_labels: A `Tensor` of type `float32`.
      a vector which contains the label/target associated with each
      example.
    sparse_indices: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `int64`.
      a list of vectors where each value is the indices which has
      corresponding weights in sparse_weights. This field maybe omitted for the
      dense approach.
    sparse_weights: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `float32`.
      a list of vectors where each value is the weight associated with
      a sparse feature group.
    dense_weights: A list with the same length as `dense_features` of `Tensor` objects with type `float32`.
      a list of vectors where the values are the weights associated
      with a dense feature group.
    example_state_data: A `Tensor` of type `float32`.
      a list of vectors containing the example state data.
    loss_type: A `string` from: `"logistic_loss", "squared_loss", "hinge_loss", "smooth_hinge_loss", "poisson_loss"`.
      Type of the primal loss. Currently SdcaSolver supports logistic,
      squared and hinge losses.
    l1: A `float`. Symmetric l1 regularization strength.
    l2: A `float`. Symmetric l2 regularization strength.
    num_loss_partitions: An `int` that is `>= 1`.
      Number of partitions of the global loss function.
    num_inner_iterations: An `int` that is `>= 1`.
      Number of iterations per mini-batch.
    adaptative: An optional `bool`. Defaults to `True`.
      Whether to use Adaptive SDCA for the inner loop.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (out_example_state_data, out_delta_sparse_weights, out_delta_dense_weights).

    out_example_state_data: A `Tensor` of type `float32`.
    out_delta_sparse_weights: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `float32`.
    out_delta_dense_weights: A list with the same length as `dense_features` of `Tensor` objects with type `float32`.
  rA   rL   rQ   rM   rN   rO   rP   N)rL   rQ   rM   rN   rO   rP   r   r   r   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   r   SExpected list for 'sparse_example_indices' argument to 'sdca_optimizer' Op, not %r.SExpected list for 'sparse_feature_indices' argument to 'sdca_optimizer' Op, not %r.List argument 'sparse_feature_indices' to 'sdca_optimizer' Op with length %d must match length %d of argument 'sparse_example_indices'.KExpected list for 'sparse_indices' argument to 'sdca_optimizer' Op, not %r.List argument 'sparse_indices' to 'sdca_optimizer' Op with length %d must match length %d of argument 'sparse_example_indices'.KExpected list for 'sparse_weights' argument to 'sdca_optimizer' Op, not %r.List argument 'sparse_weights' to 'sdca_optimizer' Op with length %d must match length %d of argument 'sparse_example_indices'.RExpected list for 'sparse_feature_values' argument to 'sdca_optimizer' Op, not %r.KExpected list for 'dense_features' argument to 'sdca_optimizer' Op, not %r.JExpected list for 'dense_weights' argument to 'sdca_optimizer' Op, not %r.vList argument 'dense_weights' to 'sdca_optimizer' Op with length %d must match length %d of argument 'dense_features'.Tnum_sparse_featuresnum_sparse_features_with_valuesnum_dense_featuresr;      )rA   )*r   r   r   r   r   r   _SdcaOptimizerOutput_maker   r   r   r   r   _dispatcher_for_sdca_optimizerr!   sdca_optimizer_eager_fallbackr#   r$   r%   r&   r   sdca_optimizerr(   r)   r*   
isinstancelisttuplelenr-   make_str
make_floatmake_int	make_boolr+   r,   r.   get_attr_get_attr_bool_get_attr_intr/   r0   )rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   r   r1   r2   r3   r4   _attr_num_sparse_features%_attr_num_sparse_features_with_values_attr_num_dense_featuresr5   r6   r7   r8   r9   r   r   r:   re   p   s  I

	









	
	







.
re   zraw_ops.SdcaOptimizerc                 C   *  t | ttfstd|  t| }t |ttfstd| t||kr.tdt||f t |ttfs;td| t||krKtdt||f t |ttfsXtd| t||krhtdt||f t |ttfsutd| t|}t |ttfstd	| t|}t |ttfstd
| t||krtdt||f t|
d}
t|d}t|d}t	|d}t	|d}|d u rd}t
|d}t| tj} t|tj}t|tj}t|tj}t|tj}t|tj}t|tj}t|tj}t|tj}t|	tj}	t| t| t| t| ||g t| t| t| |	g }d|
d|d|d|d|d|d|d|d|f}tjd|| d ||||d}t rjtd||| |d d |dd|  g |d| d   }|d d |dd  g }t|}|S )NrR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   rL   rM   rN   rO   rP   TrQ   r]   r^   r_   s   SdcaOptimizerr;   r<   rA   r`   )rf   rg   rh   r$   ri   r%   r-   rj   rk   rl   rm   r   convert_n_to_tensorr?   int64float32r>   r   r.   r0   ra   rb   )rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   r   r   rq   rr   rs   r9   r8   r3   r   r   r:   rd   q     



F
.
rd   SdcaOptimizerV2adaptivec                 C   s  t j pt  }|j}|jrwz%t|d|| |||||||||	d|
d|d|d|d|d|}t|}|W S  tj	yK } zt
|| W Y d}~nd}~w tjyT   Y nw zt| |||||||||	|
|||||||d	W S  tjyv   Y nw t| ttfstd
|  t| }t|ttfstd| t||krtdt||f t|ttfstd| t||krtdt||f t|ttfstd| t||krtdt||f t|ttfstd| t|}t|ttfstd| t|}t|ttfstd| t||kr tdt||f t|
d}
t|d}t|d}t|d}t|d}|du rEd}t|d}tj	d&i d| d|d|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d |\}}}}|dd }t rd|dd|dd!|d!d"|d"d#|d#d|dd|dd|dd|df}|j }t!d||| |dd$ |d$d$|  g |d$| d  }|dd% |d%d g }t|}|S )'a  Distributed version of Stochastic Dual Coordinate Ascent (SDCA) optimizer for

  linear models with L1 + L2 regularization. As global optimization objective is
  strongly-convex, the optimizer optimizes the dual objective at each step. The
  optimizer applies each update one example at a time. Examples are sampled
  uniformly, and the optimizer is learning rate free and enjoys linear convergence
  rate.

  [Proximal Stochastic Dual Coordinate Ascent](http://arxiv.org/pdf/1211.2717v1.pdf).<br>
  Shai Shalev-Shwartz, Tong Zhang. 2012

  $$Loss Objective = \sum f_{i} (wx_{i}) + (l2 / 2) * |w|^2 + l1 * |w|$$

  [Adding vs. Averaging in Distributed Primal-Dual Optimization](http://arxiv.org/abs/1502.03508).<br>
  Chenxin Ma, Virginia Smith, Martin Jaggi, Michael I. Jordan,
  Peter Richtarik, Martin Takac. 2015

  [Stochastic Dual Coordinate Ascent with Adaptive Probabilities](https://arxiv.org/abs/1502.08053).<br>
  Dominik Csiba, Zheng Qu, Peter Richtarik. 2015

  Args:
    sparse_example_indices: A list of `Tensor` objects with type `int64`.
      a list of vectors which contain example indices.
    sparse_feature_indices: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `int64`.
      a list of vectors which contain feature indices.
    sparse_feature_values: A list of `Tensor` objects with type `float32`.
      a list of vectors which contains feature value
      associated with each feature group.
    dense_features: A list of `Tensor` objects with type `float32`.
      a list of matrices which contains the dense feature values.
    example_weights: A `Tensor` of type `float32`.
      a vector which contains the weight associated with each
      example.
    example_labels: A `Tensor` of type `float32`.
      a vector which contains the label/target associated with each
      example.
    sparse_indices: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `int64`.
      a list of vectors where each value is the indices which has
      corresponding weights in sparse_weights. This field maybe omitted for the
      dense approach.
    sparse_weights: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `float32`.
      a list of vectors where each value is the weight associated with
      a sparse feature group.
    dense_weights: A list with the same length as `dense_features` of `Tensor` objects with type `float32`.
      a list of vectors where the values are the weights associated
      with a dense feature group.
    example_state_data: A `Tensor` of type `float32`.
      a list of vectors containing the example state data.
    loss_type: A `string` from: `"logistic_loss", "squared_loss", "hinge_loss", "smooth_hinge_loss", "poisson_loss"`.
      Type of the primal loss. Currently SdcaSolver supports logistic,
      squared and hinge losses.
    l1: A `float`. Symmetric l1 regularization strength.
    l2: A `float`. Symmetric l2 regularization strength.
    num_loss_partitions: An `int` that is `>= 1`.
      Number of partitions of the global loss function.
    num_inner_iterations: An `int` that is `>= 1`.
      Number of iterations per mini-batch.
    adaptive: An optional `bool`. Defaults to `True`.
      Whether to use Adaptive SDCA for the inner loop.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (out_example_state_data, out_delta_sparse_weights, out_delta_dense_weights).

    out_example_state_data: A `Tensor` of type `float32`.
    out_delta_sparse_weights: A list with the same length as `sparse_example_indices` of `Tensor` objects with type `float32`.
    out_delta_dense_weights: A list with the same length as `dense_features` of `Tensor` objects with type `float32`.
  ry   rL   rz   rM   rN   rO   rP   N)rL   rz   rM   rN   rO   rP   r   r   VExpected list for 'sparse_example_indices' argument to 'sdca_optimizer_v2' Op, not %r.VExpected list for 'sparse_feature_indices' argument to 'sdca_optimizer_v2' Op, not %r.List argument 'sparse_feature_indices' to 'sdca_optimizer_v2' Op with length %d must match length %d of argument 'sparse_example_indices'.NExpected list for 'sparse_indices' argument to 'sdca_optimizer_v2' Op, not %r.List argument 'sparse_indices' to 'sdca_optimizer_v2' Op with length %d must match length %d of argument 'sparse_example_indices'.NExpected list for 'sparse_weights' argument to 'sdca_optimizer_v2' Op, not %r.List argument 'sparse_weights' to 'sdca_optimizer_v2' Op with length %d must match length %d of argument 'sparse_example_indices'.UExpected list for 'sparse_feature_values' argument to 'sdca_optimizer_v2' Op, not %r.NExpected list for 'dense_features' argument to 'sdca_optimizer_v2' Op, not %r.MExpected list for 'dense_weights' argument to 'sdca_optimizer_v2' Op, not %r.yList argument 'dense_weights' to 'sdca_optimizer_v2' Op with length %d must match length %d of argument 'dense_features'.TrB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   r   r]   r^   r_   r;   r`   )ry   )"r   r   r   r   r   r   _SdcaOptimizerV2Outputrb   r   r   r   r   r    sdca_optimizer_v2_eager_fallbackr#   rf   rg   rh   r$   ri   r%   r-   rj   rk   rl   rm   r+   r,   r.   rn   ro   rp   r/   r0   )rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rz   r   r1   r2   r3   r4   rq   rr   rs   r5   r6   r7   r8   r9   r   r   r:   sdca_optimizer_v2  sN  E






	





.
r   zraw_ops.SdcaOptimizerV2c                 C   rt   )Nr{   r|   r}   r~   r   r   r   r   r   r   r   rL   rM   rN   rO   rP   Trz   r]   r^   r_   s   SdcaOptimizerV2r;   r<   ry   r`   )rf   rg   rh   r$   ri   r%   r-   rj   rk   rl   rm   r   ru   r?   rv   rw   r>   r   r.   r0   r   rb   )rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rz   r   r   rq   rr   rs   r9   r8   r3   r   r   r:   r     rx   r   ztrain.sdca_shrink_l1weightsc                 C   s   t j pt  }|j}|jrtdt| |||fd}|tur |S t| tt	fs-t
d|  t| }t|d}t|d}ztjd| |||d\}}}	}
W |	S  t
tfyo   ttdt| |||d}|tjjurn| Y S  w )	a  Applies L1 regularization shrink step on the parameters.

  Args:
    weights: A list of `Tensor` objects with type mutable `float32`.
      a list of vectors where each value is the weight associated with a
      feature group.
    l1: A `float`. Symmetric l1 regularization strength.
    l2: A `float`.
      Symmetric l2 regularization strength. Should be a positive float.
    name: A name for the operation (optional).

  Returns:
    The created Operation.
  Ksdca_shrink_l1 op does not support eager execution. Arg 'weights' is a ref.NzDExpected list for 'weights' argument to 'sdca_shrink_l1' Op, not %r.rM   rN   SdcaShrinkL1)r   rM   rN   r   r   )r   r   r   r   RuntimeError_dispatcher_for_sdca_shrink_l1r!   rf   rg   rh   r$   ri   r-   rk   r+   r,   r%   r&   r   sdca_shrink_l1r(   r)   r*   )r   rM   rN   r   r1   r2   r3   Z_attr_num_featuresr5   r6   r7   r   r   r:   r     s>   
	r   zraw_ops.SdcaShrinkL1c                 C   s   t d)Nr   )r   )r   rM   rN   r   r   r   r   r:   sdca_shrink_l1_eager_fallback  s   r   )N)TN)@__doc__collectionsZtensorflow.pythonr   Ztensorflow.python.eagerr   r   r   r   r   r-   Ztensorflow.python.frameworkr   r?   Ztensorflow.security.fuzzing.pyr   Z_atypesr   Z_op_def_registryr	   r   r
   r+   Z"tensorflow.python.util.deprecationr   Ztensorflow.python.utilr   r&   Z tensorflow.python.util.tf_exportr   typingr   r   Zadd_fallback_dispatch_listZadd_type_based_api_dispatcherZTensorFuzzingAnnotationStringZInt64r'   Z	to_raw_opr   Z_tf_type_based_dispatcherZDispatchr    r"   
namedtuplera   ZFloat32strfloatintboolre   rA   rc   rd   r   r   ry   r   r   r   r   r   r   r   r   r:   <module>   sh    
,?"
 zY @Z
,+&