You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

paddle_backend.py 22 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import absolute_import, division, print_function
  4. import paddle as pd
  5. import paddle.nn as nn
  6. _dtypeDict = ["float16", "float32", "float64", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"]
  7. # TODO NotImplemented
  8. DType = None
  9. float16 = "float16"
  10. float32 = "float32"
  11. float64 = "float64"
  12. int8 = "int8"
  13. int16 = "int16"
  14. int32 = "int32"
  15. int64 = "int64"
  16. uint8 = "uint8"
  17. uint16 = "uint16"
  18. uint32 = "uint32"
  19. uint64 = "uint64"
  20. def _getter(init_fn, **kwargs):
  21. """Return an named eager tensor."""
  22. raise NotImplementedError
  23. def set_context(**kwargs):
  24. raise Exception("Using Paddle backend,You don't need to set context")
  25. def get_tensor_shape(x):
  26. return pd.shape(x)
  27. # initializers
  28. def zeros(shape, dtype="float32"):
  29. """
  30. Creates a tensor with all elements set to zero.
  31. Parameters
  32. ----------
  33. shape : A list of integers
  34. a tuple of integers, or a 1-D Tensor of type int32.
  35. dtype : tensor
  36. The DType of an element in the resulting Tensor
  37. Returns
  38. -------
  39. A Tensor with all elements set to zero.
  40. """
  41. return pd.zeros(shape=shape, dtype=dtype)
  42. def ones(shape, dtype="float32"):
  43. """
  44. Creates a tensor with all elements set to ones.
  45. Parameters
  46. ----------
  47. shape : A list of integers
  48. a tuple of integers, or a 1-D Tensor of type int32.
  49. dtype : tensor
  50. The DType of an element in the resulting Tensor
  51. Returns
  52. -------
  53. A Tensor with all elements set to zero.
  54. """
  55. return pd.ones(shape=shape, dtype=dtype)
  56. def constant(value, shape, dtype="float32"):
  57. """
  58. Creates a constant tensor from a tensor-like object.
  59. Parameters
  60. ----------
  61. value : list
  62. A constant value (or list) of output type dtype.
  63. dtype : tensor
  64. The type of the elements of the resulting tensor.
  65. shape : tuple
  66. Optional dimensions of resulting tensor.
  67. Returns
  68. -------
  69. A Constant Tensor.
  70. """
  71. return nn.initializer.constant(value=value)
  72. def random_uniform(shape, minval=0, maxval=None, dtype="float32", seed=None):
  73. """
  74. Outputs random values from a uniform distribution.
  75. Parameters
  76. ----------
  77. shape : tuple
  78. A 1-D integer Tensor or Python array. The shape of the output tensor.
  79. minval : int
  80. The lower bound on the range of random values to generate (inclusive). Defaults to 0.
  81. maxval : int
  82. The upper bound on the range of random values to generate (exclusive). Defaults to 1 if dtype is floating point.
  83. dtype : tensor
  84. The type of the output: float16, float32, float64, int32, or int64.
  85. seed : int
  86. Used in combination with dragon.random.set_seed to create a reproducible sequence of tensors across multiple calls.
  87. Returns
  88. -------
  89. A tensor of the specified shape filled with random uniform values.
  90. """
  91. raise NotImplementedError
  92. def random_normal(shape, mean=0.0, stddev=1.0, dtype="float32", seed=None):
  93. """
  94. Outputs random values from a normal distribution.
  95. Parameters
  96. ----------
  97. shape : tuple
  98. A 1-D integer Tensor or Python array. The shape of the output tensor.
  99. mean : float
  100. The mean of the normal distribution
  101. stddev : float
  102. The standard deviation of the normal distribution.
  103. dtype : tensor
  104. The type of the output.
  105. seed : A Python integer
  106. Used to create a random seed for the distribution
  107. Returns
  108. -------
  109. A tensor of the specified shape filled with random normal values.
  110. """
  111. raise NotImplementedError
  112. def truncated_normal(shape, mean=0.0, stddev=1.0, dtype="float32", seed=None):
  113. """
  114. Outputs random values from a truncated normal distribution.
  115. Parameters
  116. ----------
  117. shape : tuple
  118. A 1-D integer Tensor or Python array. The shape of the output tensor.
  119. mean : float
  120. The mean of the normal distribution
  121. stddev : float
  122. The standard deviation of the normal distribution.
  123. dtype : tensor
  124. The type of the output.
  125. seed : A Python integer
  126. Used to create a random seed for the distribution
  127. Returns
  128. -------
  129. A tensor of the specified shape filled with random truncated normal values.
  130. """
  131. raise NotImplementedError
  132. def he_normal(shape, dtype, seed=None):
  133. """
  134. He normal initializer.
  135. Parameters
  136. ----------
  137. seed : A Python integer.
  138. Used to seed the random generator.
  139. shape : tuple
  140. A 1-D integer Tensor or Python array. The shape of the output tensor.
  141. dtype : tensor
  142. The type of the output.
  143. Returns
  144. -------
  145. A tensor of the specified shape filled with he normal values.
  146. """
  147. # shape = shape[::-1]
  148. raise NotImplementedError
  149. def Variable(initial_value, name, trainable=None):
  150. """
  151. Creates a new variable with value initial_value.
  152. Parameters
  153. ----------
  154. initial_value : tensor
  155. A Tensor, or Python object convertible to a Tensor
  156. name : str
  157. Optional name for the variable. Defaults to 'Variable' and gets uniquified automatically.
  158. Returns
  159. -------
  160. Variable
  161. """
  162. raise NotImplementedError
  163. class MatMul(object):
  164. def __init__(self):
  165. pass
  166. def __call__(self, a, b):
  167. return pd.matmul(x=a, y=b)
  168. def matmul(a, b):
  169. """
  170. Multiplies matrix a by matrix b, producing a * b.
  171. Parameters
  172. ----------
  173. a : tensor
  174. type float16, float32, float64, int32, complex64, complex128 and rank > 1.
  175. b : tensor
  176. with same type and rank as a.
  177. Returns
  178. -------
  179. A Tensor of the same type as a and b
  180. """
  181. raise NotImplementedError
  182. def add(value, bias):
  183. """
  184. Returns x + y element-wise.
  185. Parameters
  186. ----------
  187. value : tensor.
  188. Must be one of the following types: bfloat16, half, float32, float64,
  189. uint8, int8, int16, int32, int64, complex64, complex128, string.
  190. bias : tensor
  191. Must have the same type as a
  192. name : str
  193. A name for the operation
  194. Returns
  195. -------
  196. A Tensor. Has the same type as a.
  197. """
  198. raise NotImplementedError
  199. def dtypes(dt):
  200. """
  201. Data dtypes.
  202. Parameters
  203. ----------
  204. dt : string
  205. It could be 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16',
  206. 'int32', 'int64', 'float16', 'float32', 'float64', 'DType'.
  207. Returns
  208. -------
  209. Data dtypes
  210. """
  211. raise NotImplementedError
  212. class Maximum(object):
  213. def __init__(self):
  214. pass
  215. def __call__(self, x, y):
  216. raise NotImplementedError
  217. class Minimum(object):
  218. def __init__(self):
  219. pass
  220. def __call__(self, x, y):
  221. raise NotImplementedError
  222. def minimum(x, y):
  223. """
  224. Returns the min of x and y (i.e. x < y ? x : y) element-wise.
  225. Parameters
  226. ----------
  227. x : tensor.
  228. Must be one of the following types: bfloat16, half, float32, float64, int32, int64.
  229. y : A Tensor.
  230. Must have the same type as x.
  231. name : str
  232. A name for the operation (optional).
  233. Returns
  234. -------
  235. A Tensor. Has the same type as x
  236. """
  237. raise NotImplementedError
  238. class FlattenReshape(object):
  239. def __init__(self):
  240. pass
  241. def __call__(self, inputs):
  242. return pd.flatten(x=inputs, start_axis=1, stop_axis=-1)
  243. class Reshape(object):
  244. def __init__(self, shape):
  245. self.shape = shape
  246. def __call__(self, tensor):
  247. raise NotImplementedError
  248. def reshape(tensor, shape):
  249. """
  250. Reshapes a tensor.
  251. Parameters
  252. ----------
  253. tensor : tensor
  254. A Tensor.
  255. shape : tensor
  256. Defines the shape of the output tensor.
  257. Returns
  258. -------
  259. A Tensor. Has the same type as tensor
  260. """
  261. raise NotImplementedError
  262. class Concat(object):
  263. def __init__(self, axis):
  264. super(Concat, self).__init__()
  265. self.axis = axis
  266. def __call__(self, values):
  267. raise NotImplementedError
  268. def concat(values, axis):
  269. """
  270. Concatenates tensors along one dimension.
  271. Parameters
  272. ----------
  273. values : list
  274. A list of Tensor objects or a single Tensor
  275. axis : int
  276. 0-D int32 Tensor. Dimension along which to concatenate
  277. Returns
  278. -------
  279. A Tensor resulting from concatenation of the input tensors.
  280. """
  281. raise NotImplementedError
  282. def convert_to_tensor(value, dtype=None):
  283. """
  284. Converts the given value to a Tensor.
  285. Parameters
  286. ----------
  287. value : object
  288. An object whose type has a registered Tensor conversion function.
  289. dtype : optional
  290. Optional element type for the returned tensor. If missing, the type is inferred from the type of value.
  291. Returns
  292. -------
  293. A Tensor based on value.
  294. """
  295. raise NotImplementedError
  296. def sqrt(x):
  297. """
  298. Computes square root of x element-wise.
  299. Parameters
  300. ----------
  301. x : tensor
  302. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  303. Returns
  304. -------
  305. A Tensor. Has the same type as x.
  306. """
  307. raise NotImplementedError
  308. class ReduceSum(object):
  309. def __init__(self, axis):
  310. pass
  311. def construct(self, input):
  312. pass
  313. class ReduceMean(object):
  314. def __init__(self, axis):
  315. if axis == [1, 2]:
  316. self.data_format = 'NHWC'
  317. elif axis == [2, 3]:
  318. self.data_format = 'NCHW'
  319. else:
  320. raise ("`data_format` should have one of the following values: [`channels_last`, `channels_first`]")
  321. def __call__(self, inputs):
  322. raise NotImplementedError
  323. def reduce_mean(input_tensor, axis=None):
  324. """
  325. Computes the mean of elements across dimensions of a tensor.
  326. Parameters
  327. ----------
  328. input_tensor : tensor
  329. The tensor to reduce. Should have numeric type.
  330. axis : int
  331. The dimensions to reduce. If None (the default), reduces all dimensions.
  332. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  333. name : str
  334. A name for the operation (optional).
  335. Returns
  336. -------
  337. The reduced tensor.
  338. """
  339. raise NotImplementedError
  340. class ReduceMax(object):
  341. def __init__(self, axis):
  342. if axis == [1, 2]:
  343. self.data_format = 'NHWC'
  344. elif axis == [2, 3]:
  345. self.data_format = 'NCHW'
  346. else:
  347. raise ("`data_format` should have one of the following values: [`channels_last`, `channels_first`]")
  348. def __call__(self, inputs):
  349. raise NotImplementedError
  350. def reduce_max(input_tensor, axis=None):
  351. """
  352. Computes the maximum of elements across dimensions of a tensor.
  353. Parameters
  354. ----------
  355. input_tensor : tensor
  356. The tensor to reduce. Should have real numeric type.
  357. axis : int
  358. The dimensions to reduce. If None (the default), reduces all dimensions.
  359. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  360. name : str
  361. A name for the operation (optional).
  362. Returns
  363. -------
  364. The reduced tensor.
  365. """
  366. raise NotImplementedError
  367. def reduce_min(input_tensor, axis=None):
  368. """
  369. Computes the minimum of elements across dimensions of a tensor.
  370. Parameters
  371. ----------
  372. input_tensor : tensor
  373. The tensor to reduce. Should have real numeric type.
  374. axis : int
  375. The dimensions to reduce. If None (the default), reduces all dimensions.
  376. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  377. name : str
  378. A name for the operation (optional).
  379. Returns
  380. -------
  381. The reduced tensor.
  382. """
  383. raise NotImplementedError
  384. class Pad(object):
  385. def __init__(self, paddings, mode="REFLECT"):
  386. if mode not in ['CONSTANT', 'REFLECT', 'SYMMETRIC']:
  387. raise Exception("Unsupported mode: {}".format(mode))
  388. if mode == 'SYMMETRIC':
  389. mode = 'EDGE'
  390. self.paddings = paddings
  391. self.mode = mode
  392. def __call__(self, x):
  393. raise NotImplementedError
  394. def pad(tensor, paddings, mode='CONSTANT', constant_values=0):
  395. """
  396. Pads a tensor.
  397. Parameters
  398. ----------
  399. tensor : tensor
  400. A Tensor.
  401. paddings : tuple
  402. A tuple of type int32.
  403. mode : str
  404. One of "CONSTANT", "REFLECT", or "SYMMETRIC" (case-insensitive)
  405. constant_values : int
  406. In "CONSTANT" mode, the scalar pad value to use. Must be same type as tensor.
  407. Returns
  408. -------
  409. A Tensor. Has the same type as tensor.
  410. """
  411. raise NotImplementedError
  412. class Unstack(object):
  413. def __init__(self, axis, num=None):
  414. self.axis = axis
  415. self.num = num
  416. def __call__(self, values):
  417. raise NotImplementedError
  418. class Stack(object):
  419. def __init__(self, axis):
  420. self.axis = axis
  421. def __call__(self, values):
  422. raise NotImplementedError
  423. def stack(values, axis=0):
  424. """
  425. Stacks a list of rank-R tensors into one rank-(R+1) tensor.
  426. Parameters
  427. ----------
  428. values : list
  429. A list of Tensor objects with the same shape and type.
  430. axis : int
  431. An int. The axis to stack along. Defaults to the first dimension.
  432. Negative values wrap around, so the valid range is [-(R+1), R+1).
  433. Returns
  434. -------
  435. A stacked Tensor with the same type as values.
  436. """
  437. raise NotImplementedError
  438. class Meshgrid(object):
  439. def __init__(self, indexing='xy'):
  440. super(Meshgrid, self).__init__()
  441. self.index = indexing
  442. def __call__(self, inputs):
  443. pass
  444. def meshgrid(x, y):
  445. """
  446. Broadcasts parameters for evaluation on an N-D grid.
  447. Parameters
  448. ----------
  449. x : tensor
  450. Tensors with rank 1.
  451. y : tensor
  452. Tensors with rank 1.
  453. Returns
  454. -------
  455. A list of N Tensors with rank N.
  456. """
  457. pass
  458. def range(start, limit=None, delta=1, dtype=None):
  459. """
  460. Creates a sequence of numbers.
  461. Parameters
  462. ----------
  463. start : tensor
  464. A 0-D Tensor (scalar). Acts as first entry in the range if limit is not None;
  465. otherwise, acts as range limit and first entry defaults to 0.
  466. limit : tensor
  467. A 0-D Tensor (scalar). Upper limit of sequence, exclusive. If None,
  468. defaults to the value of start while the first entry of the range defaults to 0.
  469. delta : tensor
  470. A 0-D Tensor (scalar). Number that increments start. Defaults to 1.
  471. dtype : type
  472. The type of the elements of the resulting tensor.
  473. Returns
  474. -------
  475. An 1-D Tensor of type dtype.
  476. """
  477. raise NotImplementedError
  478. class ExpandDims(object):
  479. def __init__(self, axis):
  480. pass
  481. def construct(self, input):
  482. pass
  483. def expand_dims(input, axis):
  484. """
  485. Inserts a dimension of 1 into a tensor's shape.
  486. Parameters
  487. ----------
  488. input : tensor
  489. A Tensor.
  490. axis : int
  491. 0-D (scalar). Specifies the dimension index at which to expand the shape of input.
  492. Must be in the range [-rank(input) - 1, rank(input)].
  493. Returns
  494. -------
  495. A Tensor with the same data as input, but its shape has an additional dimension of size 1 added.
  496. """
  497. raise NotImplementedError
  498. class Tile(object):
  499. def __init__(self):
  500. pass
  501. def __call__(self, input, multiples):
  502. raise NotImplementedError
  503. def tile(input, multiples):
  504. """
  505. Constructs a tensor by tiling a given tensor.
  506. Parameters
  507. ----------
  508. input : tensor
  509. A Tensor. 1-D or higher.
  510. multiples : tensor
  511. Must be one of the following types: int32, int64. 1-D.
  512. Length must be the same as the number of dimensions in input
  513. Returns
  514. -------
  515. A Tensor. Has the same type as input.
  516. """
  517. raise NotImplementedError
  518. class Cast(object):
  519. def __init__(self, dtype):
  520. pass
  521. def __call__(self, input):
  522. pass
  523. def cast(x, dtype):
  524. """
  525. Casts a tensor to a new type.
  526. Parameters
  527. ----------
  528. x : tensor
  529. A Tensor or SparseTensor or IndexedSlices of numeric type.
  530. It could be uint8, uint16, uint32, uint64, int8, int16, int32, int64, float16, float32, float64.
  531. dtype : dtpye
  532. The destination type. The list of supported dtypes is the same as x
  533. Returns
  534. -------
  535. A Tensor or SparseTensor or IndexedSlices with same shape as x and same type as dtype.
  536. """
  537. raise NotImplementedError
  538. class Transpose(object):
  539. def __init__(self, perm, conjugate=False):
  540. self.perm = perm
  541. if conjugate:
  542. raise ("The conjugate Parameters not supported")
  543. def __call__(self, a):
  544. raise NotImplementedError
  545. def transpose(a, perm=None, conjugate=False):
  546. """
  547. Transposes a.
  548. Parameters
  549. ----------
  550. a : tensor
  551. A Tensor.
  552. perm : int
  553. A permutation of the dimensions of a.
  554. conjugate : bool
  555. Setting it to True is mathematically equivalent to ms.math.conj(ms.transpose(input)).
  556. Returns
  557. -------
  558. A transposed Tensor.
  559. """
  560. raise NotImplementedError
  561. def gather_nd(params, indices, batch_dims=0):
  562. """
  563. Gather slices from params into a Tensor with shape specified by indices.
  564. Parameters
  565. ----------
  566. params : tensor
  567. The tensor from which to gather values.
  568. indices : tensor
  569. Must be one of the following types: int32, int64. Index tensor.
  570. batch_dims : int
  571. An integer or a scalar 'Tensor'. The number of batch dimensions.
  572. Returns
  573. -------
  574. A Tensor. Has the same type as params.
  575. """
  576. pass
  577. def clip_by_value(t, clip_value_min, clip_value_max):
  578. """
  579. Clips tensor values to a specified min and max.
  580. Parameters
  581. ----------
  582. t : tensor
  583. A Tensor or IndexedSlices
  584. clip_value_min : tensor
  585. A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The minimum value to clip by
  586. clip_value_max : tensor
  587. A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The minimum value to clip by
  588. Returns
  589. -------
  590. A clipped Tensor or IndexedSlices.
  591. """
  592. pass
  593. def split(value, num_or_size_splits, axis=0, num=None):
  594. """
  595. Splits a tensor into sub tensors.
  596. Parameters
  597. ----------
  598. value : tensor
  599. The Tensor to split.
  600. num_or_size_splits : list
  601. Either an integer indicating the number of splits along split_dim or a 1-D integer Tensor or
  602. Python list containing the sizes of each output tensor along split_dim.
  603. axis : int
  604. The dimension along which to split. Must be in the range [-rank(value), rank(value)). Defaults to 0.
  605. num : int
  606. used to specify the number of outputs when it cannot be inferred from the shape of size_splits.
  607. Returns
  608. -------
  609. Tensor objects resulting from splitting value.
  610. """
  611. pass
  612. def floor(x):
  613. raise NotImplementedError
  614. def gather(params, indices):
  615. raise NotImplementedError
  616. def linspace(start, stop, num):
  617. raise NotImplementedError
  618. def slice(inputs, starts, sizes):
  619. raise NotImplementedError
  620. def add_n(inputs):
  621. raise NotImplementedError
  622. class OneHot(object):
  623. def __init__(self, axis=-1, depth=1, on_value=1.0, off_value=0.0, dtype="float32"):
  624. self.depth = depth
  625. self.dtype = dtype
  626. def __call__(self, indices):
  627. raise NotImplementedError
  628. class L2Normalize(object):
  629. def __init__(self, axis=None, epsilon=1e-12):
  630. super(L2Normalize, self).__init__()
  631. pass
  632. def __call__(self, input, *args, **kwargs):
  633. pass
  634. class EmbeddingLookup(object):
  635. def __init__(self, max_norm=None):
  636. self.max_norm = max_norm
  637. def __call__(self, params, ids, *args, **kwargs):
  638. pass
  639. class NCELoss(object):
  640. def __init__(self, num_true=1, sampled_values=None, remove_accidental_hits=False):
  641. super(NCELoss, self).__init__()
  642. def __call__(self, weights, biases, labels, inputs, num_sampled, num_classes):
  643. pass
  644. class Not_equal(object):
  645. def __init__(self):
  646. pass
  647. def __call__(self, x, y):
  648. pass
  649. class Count_nonzero(object):
  650. def __init__(self, keepdims=None, dtype="int64"):
  651. pass
  652. def __call__(self, *args, **kwargs):
  653. pass
  654. class Resize:
  655. def __init__(self, scale, method, antialias=False, data_format='channels_last', ksize=None):
  656. if method not in ['nearest', 'linear', 'bilinear']:
  657. raise ('Current resize does not support this method.')
  658. if method == 'bilinear':
  659. method = 'linear'
  660. self.method = method
  661. self.antialias = antialias
  662. self.scale = scale
  663. if data_format != 'channel_last':
  664. raise Exception("UpSampling2d resize_images only support channel_last")
  665. def __call__(self, inputs):
  666. raise NotImplementedError
  667. def resize(inputs, output_size, method, antialias):
  668. raise NotImplementedError
  669. class ZeroPadding1D(object):
  670. def __init__(self):
  671. pass
  672. def __call__(self, padding):
  673. raise NotImplementedError
  674. class ZeroPadding2D(object):
  675. def __init__(self):
  676. pass
  677. def __call__(self, padding):
  678. raise NotImplementedError
  679. class ZeroPadding3D(object):
  680. def __init__(self):
  681. pass
  682. def __call__(self, padding):
  683. raise NotImplementedError
  684. class Sign(object):
  685. def __init__(self):
  686. pass
  687. def __call__(self, x):
  688. raise NotImplementedError
  689. def ceil(x):
  690. raise NotImplementedError
  691. def multiply(x, y):
  692. raise NotImplementedError
  693. def divide(x, y):
  694. raise NotImplementedError
  695. def identity(x):
  696. raise NotImplementedError
  697. class BatchToSpace(object):
  698. def __init__(self, block_size, crops):
  699. super(BatchToSpace, self).__init__()
  700. pass
  701. def __call__(self, input_x):
  702. raise NotImplementedError
  703. class DepthToSpace(object):
  704. def __init__(self, block_size, data_format='NHWC'):
  705. pass
  706. def __call__(self, input):
  707. raise NotImplementedError

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.