LoginSignup
0
0

More than 5 years have passed since last update.

TensorFlow > stringリストをTensor objectsに変換する > names_tf = ops.convert_to_tensor(names_str)

Last updated at Posted at 2016-11-20
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

Deep LearningのフレームワークTensorFlowを学習中。

上記のリンクでstringリストをTensor objectsに変換する方法が紹介されていた。 

試してみた。

string_to_tensor.py
from tensorflow.python.framework import ops
from tensorflow.python.framework import dtypes

names_str = [ 'Janeway', 'Tuvok', '7of9' ]

names_tf = ops.convert_to_tensor(names_str, dtype=dtypes.string)

print(names_tf)
結果
$ python string_to_tensor.py 
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Tensor("Const:0", shape=(3,), dtype=string)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0