TensorFlow API Changes

텐서플로우 v0.12 버전이 릴리즈되면서 파이썬 API 가 일부 변경되었습니다. 혼돈을 줄 수 있는 것들을 바로 잡고 또 가능하면 NumPy 와 일관성을 가지게 하려는 것 같습니다. 이런 API 변경은 앞으로도 조금 더 발생할 수 있을 것으로 예상됩니다. 아직 1.0 버전이 언제 나올지 알 수는 없지만 1.0 이후에는 하위 버전 호환성에 대해 더 엄격하게 관리할 것이라 합니다. 관련된 내용은 구글 그룹스에 올린 구글 브레인팀의 애드류 셀(Andrew Selle)의 포스팅과 텐서플로우 깃허브의 릴리즈 노트의 ‘Breaking Changes to the API’ 섹션을 참고하세요.

  • tf.pack / tf.unpack –> tf.stack / tf.unstack
    • v0.12: stack/unstack 추가, pack/unpack 은 stack/unstack 을 단순 wrapping
    • master: pack/unpack 에 deprecated 메세지 추가
  • tf.concat(concat_dim, values) –> tf.concat_v2(values, axis)
    • v0.12: concat_v2 추가
    • master: concat 에 deprecated 메세지 추가
  • tf.split(split_dim, num_splits, value) –> tf.split(value, num_or_size_splits, axis)
    • v0.12: split_v(value, size_splits, split_dim) 추가
    • master: split(value, num_or_size_splits, axis) 로 변경
  • tf.sparse_split(split_dim, num_split, sp_input) –> tf.sparse_split(sp_input, num_split, axis)
    • master: sparse_split(sp_input, num_split, axis) 로 변경
  • tf.reverse(tensor, dims) –> tf.reverse(tensor, axis)
    • v0.12: reverse_v2(tensor, axis) 추가
    • master: reverse 가 바뀌고, v1.0 이후 reverse_v2 가 deprecated 될 예정
  • tf.round –> banker’s rounding
    • v0.12: 파이썬의 banker’s rounding 으로 변경, 짝수로 반올림/내림
  • dimension, dim, ~indices, ~dim, ~axes 키워드 파라미터 –> axis 로 통일
    • v0.12: 기존 파라미터와 axis 모두 유지, 향후 기존 파라미터 삭제 예정
    • tf.argmax: dimension –> axis
      tf.argmin: dimension –> axis
      tf.count_nonzero: reduction_indices –> axis
      tf.expand_dims: dim –> axis
      tf.reduce_all: reduction_indices –> axis
      tf.reduce_any: reduction_indices –> axis
      tf.reduce_join: reduction_indices –> axis
      tf.reduce_logsumexp: reduction_indices –> axis
      tf.reduce_max: reduction_indices –> axis
      tf.reduce_mean: reduction_indices –> axis
      tf.reduce_min: reduction_indices –> axis
      tf.reduce_prod: reduction_indices –> axis
      tf.reduce_sum: reduction_indices –> axis
      tf.reverse_sequence: batch_dim –> batch_axis, seq_dim –> seq_axis
      tf.sparse_concat: concat_dim –> axis
      tf.sparse_reduce_sum: reduction_axes –> axis
      tf.sparse_reduce_sum_sparse: reduction_axes –> axis
      tf.sparse_split: split_dim –> axis
  • tf.listdiff –> tf.setdiff1d
    • v0.12: setdiff1d 추가
    • master: listdiff 에 deprecated 메세지 추가
  • tf.select –> tf.where
    • v0.12: where 추가
    • master: select 삭제
  • tf.inv –> tf.reciprocal
    • v0.12: inv –> reciprocal 이름 변경
  • tf.SparseTensor.shape –> tf.SparseTensor.dense_shape
    • master: shape –> dense_shape 이름변경
  • tf.SparseTensorValue.shape –> tf.SparseTensorValue.dense_shape
    • master: shape –> dense_shape 이름 변경
  • all_variables –> global_variables , initialize_all_variables -> global_variables_initializer , initialize_local_variables -> local_variables_initializer
    • v0.12: 이름 변경 및 deprecated 메세지 추가
  • zeros_initializer –> 함수 리턴으로 변경
    • master: ones_initializer 와 동일한 리턴 형식으로 변경

이 외에도 tf.nn.sparse_softmax_cross_entropy_with_logits, tf.nn.softmax_cross_entropy_with_logits, tf.nn.sigmoid_cross_entropy_with_logits 의 파라미터 순서가 바뀔 예정이라고 합니다.(아마도 널리 통용되는 크로스 엔트로피 공식의 기호와 순서가 반대여서 그런 것 같습니다)

(업데이트)

  • v0.12: TensorFlowEstimator() 가 삭제되었습니다. 대신 Estimator() 가 권장됩니다.

TensorFlow API Changes”에 대한 4개의 생각

  1. 권오성

    tf.split(split_dim, num_splits, value) –> tf.split(value, num_or_size_splits, axis)
    v0.12: split_v(value, size_splits, split_dim) 추가
    master: split(value, num_or_size_splits, axis) 로 변경되었다고 되어있고, 최신 api문서에도 변경된 것으로 나와있는데,

    제가 gpu버전으로 설치한 후, 동작하니 아직도 예전 split함수로 동작하네요. 대신 split_v를 사용하면 최신 api로 동작은 합니다.

    어찌된 영문일까요?

    t1, t2 = tf.split(t, tf.constant([1, 2]), 1)

    C:\Users\great\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in split(split_dim, num_split, value, name)
    1232 num_split=num_split,
    1233 value=value,
    -> 1234 name=name)
    1235
    1236

    좋아요

    응답
    1. 로드홈 글의 글쓴이

      텐서플로우 최신 문서는 master 브랜치를 기준으로 하고 있어서 그런 것 같습니다. 0.12 버전에는 split 과 split_v 가 모두 존재하고 있습니다. 아마 다음 버전에는 split_v 가 빠지고 split 함수가 변경되지 않을까 생각됩니다. 🙂

      좋아요

      응답

댓글 남기기

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.